用户:
SCS_user_Ro5e1laiki查看:0 回复:2 评论:0 创建时间:2022-03-13T16:11:57
#再次说明,版权所有
#引用模块并且当模块缺失的时候自动安装。
import os
import tkinter.messagebox
import tkinter as tk
import random #引入随机数模块
from tkinter import *#引入全局变量的tkinter
import time
import sys
import Info_Manager_RP
import Auto_Q
#窗口布局
root_3 = tk.Tk()
root_3.withdraw()
window = Toplevel()#召唤一个名为window的窗口
window.title('Watch Dog b4'); window.geometry('300x200'); window.resizable(width=False, height=False) #给窗口设定状态
ByHuKai = Label(window,text='By 风趣的大布丁').place(x=250,y=180); WatchDogName = Label(window,text='Watch Dog beta 4.0 Checker').place(x=60); UserTS = Label(window,text='输入账号').place(x=10,y=20); PaswTS = Label(window,text='输入密码').place(x=10,y=40)
UserInput = tk.Entry(window) #这个不能改成一行,改成一行会无法正常get
UserInput.place(x=70,y=20) #通过绝对坐标放置账号输入框
PaswInput = tk.Entry(window, show='*')#这个不能改成一行,改成一行会无法正常get
PaswInput.place(x=70,y=40)#通过绝对坐标放置密码输入框
#变量设定,赋值
global NewUser,NewPasw,NewName,User,Pasw,a,b,Save,AutoLoginOrNot,ReadBeforeCheckOrNot,Tool_list,var4
NewUser,NewPasw,NewName,User_Save,Pasw_Save,User_Saved,Result = None,None,None,None,None,None,False
var1,var2,var3,var4,var5,var6,var7,var8,var9,var10 = tk.IntVar(),tk.IntVar(),tk.StringVar(),tk.IntVar(),tk.StringVar(),tk.StringVar(),tk.StringVar(),tk.StringVar(),tk.IntVar(),tk.StringVar()
JingYan = tk.IntVar(); ShuXueWinTime = tk.IntVar(); YingYuWinTime = tk.IntVar(); ShuXueLoseTime = tk.IntVar(); YingYuLoseTime = tk.IntVar(); Score = tk.IntVar(); Name = tk.StringVar()
#函数定义
def startcode():
global var4
messagebox.askokcancel(title=('Success!'),message='成功登入益学系统')
window.destroy()
root_3.deiconify(); root_3.title('益学系统 beta 3.0'); root_3.geometry('600x350+300+300'); root_3.resizable(width=False, height=False)
#Background = Canvas(root_3,width=1000,height=1000); Background.place(x=0,y=0); Image_8 = tk.PhotoImage(file = 'Image\Backgrounds.png'); Background.create_image(0,0,anchor=NW,image=Image_8)
#root_3.attributes('-alpha',0.85)
root_3.iconphoto(False, tk.PhotoImage(file='Image\icon.png'))#放置程序的图标,不过很抱歉这个图片我没做好,不怎么会用ps
#root_3.overrideredirect(True)
#root_3.attributes('-toolwindow', 1)
ByHuKai = Label(root_3,text='By 大布丁',font=('华文行楷')).place(x=1135,y=725)
Title = Label(root_3,text='益学系统',font=('华文行楷',50)).place(x=170,y=10)
def Turn_On_ZhiShiJingSai():
Score.set(0)
global Tool_list
root_1 = Toplevel()
root_1.title('数学竞赛')
root_1.geometry('300x400')
root_1.resizable(width=False, height=False)
def Quit():
JingYan.set(JingYan.get()+Score.get())
root_1.destroy()
def Answer_Check():
global Tool_list
Choose = (var4.get())
if Tool_list[Choose] == (Tool_list[1]):
ShuXueWinTime.set(ShuXueWinTime.get()+1)
Score.set(Score.get()+1)
tkinter.messagebox.askokcancel(title=('Correct!'),message='答案正确')
else:
ShuXueLoseTime.set(ShuXueLoseTime.get()+1)
Score.set(Score.get()-1)
tkinter.messagebox.showerror(title=('Wrong!'),message='答案错误')
var4.set(0)
Placer()
def Choose_A():
var4.set(2)
def Choose_B():
var4.set(3)
def Choose_C():
var4.set(4)
def Choose_D():
var4.set(5)
def Placer():
global Tool_list
Tool_list = Auto_Q.Auto_SuSuan_Q()
var3.set(Tool_list[0])
var5.set(Tool_list[2])
var6.set(Tool_list[3])
var7.set(Tool_list[4])
var8.set(Tool_list[5])
Tool_list = Auto_Q.Auto_SuSuan_Q()
Math_Title = Label(root_1,font=('微软雅黑',20),textvariable=var3)
Math_Title.place(x=70,y=60)
A_Title = Label(root_1,font=('微软雅黑',15),textvariable=var5)
A_Title.place(x=80,y=120)
B_Title = Label(root_1,font=('微软雅黑',15),textvariable=var6)
B_Title.place(x=80,y=160)
C_Title = Label(root_1,font=('微软雅黑',15),textvariable=var7)
C_Title.place(x=80,y=200)
D_Title = Label(root_1,font=('微软雅黑',15),textvariable=var8)
D_Title.place(x=80,y=240)
Placer()
#放置ABCD四个按钮并提示无限小数四舍五入为两位小数
Label(root_1,text='得分:',font=('宋体',12,'bold')).place(x=200,y=0); Label(root_1,textvariable=Score,font=('宋体',12,'bold')).place(x=250,y=0)
A_TS = Button(root_1,text='A',font=('微软雅黑',12),command=Choose_A).place(x=50,y=115)
B_TS = Button(root_1,text='B',font=('微软雅黑',12),command=Choose_B).place(x=50,y=155)
C_TS = Button(root_1,text='C',font=('微软雅黑',12),command=Choose_C).place(x=50,y=195)
D_TS = Button(root_1,text='D',font=('微软雅黑',12),command=Choose_D).place(x=50,y=235)
Title_TS = Label(root_1,text='PS:除法是整除',font=('微软雅黑',12)).place(x=50,y=20)
root_1.protocol("WM_DELETE_WINDOW", Quit)
QueDing = tk.Button(root_1,text='确定',font=('微软雅黑',12),command=Answer_Check).place(x=100,y=280)
QuitButton = tk.Button(root_1,text='退出',font=('微软雅黑',12),command=Quit).place(x=150,y=280)
root_1.mainloop()
def JingChaZhuaXiaoTou():
A,B,C,D,E = tk.StringVar(),tk.StringVar(),tk.StringVar(),tk.StringVar(),tk.StringVar()
Press = tk.StringVar(); Turn = tk.IntVar()
root_4 = Toplevel(); root_4.title('警察抓小偷'); root_4.geometry('400x300'); root_4.resizable(width=False, height=False)
def Start_Game():
Start.destroy()
A.set('警察')
B.set('小偷')
C.set('C')
D.set('D')
E.set('E')
Turn.set(0)
def Check():
if Press.get() == 'A':
if Turn.get() == 0:
if C.get() == '小偷':
messagebox.askokcancel(title='检测到异常',message='请重新选择')
else:
A.set('小偷')
if B.get() == '小偷':
B.set('B')
if D.get() == '小偷':
D.set('D')
if E.get() == '小偷':
E.set('E')
Turn.set(1)
if Turn.get() == 1:
if C.get() == '警察':
messagebox.askokcancel(title='检测到异常',message='请重新选择')
else:
A.set('警察')
if B.get() == '警察':
B.set('B')
if D.get() == '警察':
D.set('D')
if E.get() == '警察':
E.set('E')
Turn.set(0)
if Press.get() == 'B':
if Turn.get() == 0:
if D.get() == '小偷' or E.get() == '小偷':
messagebox.askokcancel(title='检测到异常',message='请重新选择')
else:
B.set('小偷')
if A.get() == '小偷':
A.set('A')
if C.get() == '小偷':
C.set('C')
Turn.set(1)
if Turn.get() == 1:
if D.get() == '警察' or E.get() == '警察':
messagebox.askokcancel(title='检测到异常',message='请重新选择')
else:
B.set('警察')
if A.get() == '警察':
A.set('A')
if C.get() == '警察':
C.set('C')
Turn.set(0)
if Press.get() == 'C':
if Turn.get() == 0:
if A.get() == '小偷' or E.get() == '小偷':
messagebox.askokcancel(title='检测到异常',message='请重新选择')
else:
C.set('小偷')
if B.get() == '小偷':
B.set('B')
if D.get() == '小偷':
D.set('D')
Turn.set(1)
if Turn.get() == 1:
if A.get() == '警察' or E.get() == '警察':
messagebox.askokcancel(title='检测到异常',message='请重新选择')
else:
C.set('警察')
if B.get() == '警察':
B.set('B')
if D.get() == '警察':
D.set('D')
Turn.set(0)
if Press.get() == 'D':
if Turn.get() == 0:
if B.get() == '小偷':
messagebox.askokcancel(title='检测到异常',message='请重新选择')
else:
D.set('小偷')
if A.get() == '小偷':
A.set('A')
if D.get() == '小偷':
D.set('D')
if E.get() == '小偷':
E.set('E')
Turn.set(1)
if Turn.get() == 1:
if B.get() == '警察':
messagebox.askokcancel(title='检测到异常',message='请重新选择')
else:
D.set('警察')
if A.get() == '警察':
A.set('A')
if D.get() == '警察':
D.set('D')
if E.get() == '警察':
E.set('E')
Turn.set(0)
if Press.get() == 'E':
if Turn.get() == 0:
if B.get() == '小偷' or C.get() == '小偷':
messagebox.askokcancel(title='检测到异常',message='请重新选择')
else:
E.set('小偷')
if A.get() == '小偷':
A.set('A')
if D.get() == '小偷':
D.set('D')
Turn.set(1)
if Turn.get() == 1:
if B.get() == '警察' or C.get() == '警察':
messagebox.askokcancel(title='检测到异常',message='请重新选择')
else:
E.set('警察')
if A.get() == '警察':
A.set('A')
if D.get() == '警察':
D.set('D')
Turn.set(0)
def Press_A():
Press.set('A')
Check()
def Press_B():
Press.set('B')
Check()
def Press_C():
Press.set('C')
Check()
def Press_D():
Press.set('D')
Check()
def Press_E():
Press.set('E')
Check()
a = Button(root_4,textvariable=A,font=('宋体',12,'bold'),command=Press_A,width=5,height=3)
a.place(x=130,y=40)
b = Button(root_4,textvariable=B,font=('宋体',12,'bold'),command=Press_B,width=5,height=3)
b.place(x=50,y=110)
c = Button(root_4,textvariable=C,font=('宋体',12,'bold'),command=Press_C,width=5,height=3)
c.place(x=75,y=190)
d = Button(root_4,textvariable=D,font=('宋体',12,'bold'),command=Press_D,width=5,height=3)
d.place(x=155,y=190)
e = Button(root_4,textvariable=E,font=('宋体',12,'bold'),command=Press_E,width=5,height=3)
e.place(x=195,y=110)
Start = Button(root_4,text='开始',command=Start_Game)
Start.place(x=0,y=0)
root_4.mainloop()
def Drawing():
'''
目前切换颜色的单选框代码出现了问题,
我们会尽快修复,在此之前先用按钮顶上
'''
global Pen_color
Pen_color,mode = tk.StringVar(),tk.StringVar()
def SetColor_1():
Pen_color.set('red')
def SetColor_2():
Pen_color.set('blue')
def SetColor_3():
Pen_color.set('green')
root = Tk(); root.title('画板'); root.geometry('600x450'); root.resizable(width=False,height=False)
canvas = Canvas(root, width=400, height=350, background='white'); canvas.place(x=0,y=0)
Label(root,text='颜色:').place(x=7,y=355)
Button(root,text='红色',command=SetColor_1).place(x=7,y=375); Button(root,text='蓝色',command=SetColor_2).place(x=7,y=395); Button(root,text='绿色',command=SetColor_3).place(x=7,y=415)#这里本来想做单选框的,但是我的单选框代码出了一些问题,所以只能暂时将单选框换为按钮代替一下。
#Radiobutton(root,text='红色',value='red',variable=Pen_color).place(x=7,y=375); Radiobutton(root,text='蓝色',value='blue',variable=Pen_color).place(x=7,y=395); Radiobutton(root,text='绿色',value='green',variable=Pen_color).place(x=7,y=415)
Button(root,text='清空',command=(lambda x=ALL: canvas.delete(x))).place(x=400,y=10)
def paint(event):
x1,y1,x2,y2 = (event.x - 1),(event.y - 1),(event.x + 1),(event.y + 1)
Draw = canvas.create_oval(x1, y1, x2, y2, fill=(Pen_color.get()))
canvas.bind("<B1-Motion>", paint)
mainloop()
def y_kx_b():
try:
import matplotlib.pyplot as TuXiang
import numpy as np
except:
Install_matplotlib = messagebox.askokcancel(title=('模块缺失!'),message='WatchDog发现您的电脑缺失画图像程序所需模块\n点击确定自动安装')
if Install_matplotlib:
os.system('pip install matplotlib')
os.system('pip install numpy')
import matplotlib.pyplot as TuXiang
import numpy as np
else:
os._exit(0)
def HuaHanShu():
x=np.arange(int(Start_Inputer.get()),int(End_Inputer.get()))
y=(int(K_Inputer.get())*x+int(B_Inputer.get()))
TuXiang.plot(x,y)
TuXiang.title('y=kx+b!!!',fontsize=24)
TuXiang.xlabel("X",fontsize=14)
TuXiang.ylabel("Y",fontsize=14)
TuXiang.tick_params(axis='both',labelsize=17)
TuXiang.show()
root_6 = Toplevel(); root_6.title('画图像'); root_6.geometry('500x500'); root_6.resizable(width=False,height=False)
Label(root_6,text='画一次函数(y=kx+b)',font=('宋体',12,'bold')).place(x=19,y=20); Label(root_6,text='输入k',font=('宋体',11,'bold')).place(x=16,y=40); Label(root_6,text='输入b',font=('宋体',11,'bold')).place(x=16,y=60); Label(root_6,text='x的起始值',font=('宋体',11,'bold')).place(x=16,y=80); Label(root_6,text='x的结束值',font=('宋体',11,'bold')).place(x=16,y=100)
K_Inputer = Entry(root_6,width=6); K_Inputer.place(x=110,y=40); B_Inputer = Entry(root_6,width=6); B_Inputer.place(x=110,y=60); Start_Inputer = Entry(root_6,width=6); Start_Inputer.place(x=110,y=80); End_Inputer = Entry(root_6,width=6); End_Inputer.place(x=110,y=100)
Button(root_6,text='确定',width=6,height=2,command=HuaHanShu).place(x=55,y=120)
def String_processing():
'''
引用一个可以复制黏贴的模块,把加密/解密后的字符黏贴在剪切板中,并如果引用错误就询问是否下载,不下载自毁程序
'''
try:
import pyperclip
except:
Install_Pyperclip = messagebox.askokcancel(title=('模块缺失!'),message='WatchDog发现您的电脑缺失Pyperclip模块\n点击确定自动安装')
if Install_Pyperclip:
os.system('pip install pyperclip')
import pyperclip
else:
os._exit(0)
def Caesar_encode():
Text = Plaintext.get()
Message=''
ToolVar_1 = 0
while ToolVar_1 < len(Text):
plaintext = Text[ToolVar_1]
if 'a' <= plaintext <= 'u' or 'A' <= plaintext <='U':
plaintext=chr(ord(plaintext)+5)
elif 'v' <= plaintext <= 'z' or 'V' <= plaintext <= 'Z':
plaintext = chr(ord(plaintext)-21)
elif '0' <= plaintext <= '4':
plaintext = int(plaintext) + 5
elif '5' <= plaintext <= '9':
plaintext = int(plaintext) - 5
Message = Message + str(plaintext)
ToolVar_1 = ToolVar_1 + 1
pyperclip.copy(Message)
messagebox.askokcancel(title=('加密成功'),message='WatchDog已成功对字符进行凯撒加密!\n并已黏贴至剪切板上')
def Caesar_decode():
Text = Ciphertext.get()
Message_1=''
ToolVar_1 = 0
while ToolVar_1 < len(Text):
ciphertext = Text[ToolVar_1]
if 'f' <= ciphertext <= 'z' or 'F' <= ciphertext <='Z':
ciphertext=chr(ord(ciphertext)-5)
elif 'a' <= ciphertext <= 'e' or 'A' <= ciphertext <= 'E':
ciphertext = chr(ord(ciphertext)+21)
elif '0' <= ciphertext <= '4':
ciphertext = int(ciphertext) + 5
elif '5' <= ciphertext <= '9':
ciphertext = int(ciphertext) - 5
Message_1 = Message_1 + str(ciphertext)
ToolVar_1 = ToolVar_1 + 1
pyperclip.copy(Message_1)
messagebox.askokcancel(title=('解密成功'),message='WatchDog已成功对字符进行凯撒解密!\n并已黏贴至剪贴板上')
#创建窗口,放置输入框,标签,按钮之类的东西,因为没有可读性所以折叠起来。
root_5 = Toplevel(); root_5.title('字符处理'); root_5.geometry('500x500'); root_5.resizable(width=False, height=False)
Label(root_5,text='凯撒加密',font=('宋体',20,'bold')).place(x=10,y=10); Label(root_5,text='加密',font=('宋体',15,'bold')).place(x=8,y=40); Label(root_5,text='解密',font=('宋体',15,'bold')).place(x=70,y=40)
Plaintext = Entry(root_5, width=5); Ciphertext = Entry(root_5, width=5); Plaintext.place(x=10,y=65); Ciphertext.place(x=70,y=65)
Button(root_5, text='确定', width=4, height=1,command=Caesar_encode).place(x=13,y=100); Button(root_5, text='确定', width=4, height=1,command=Caesar_decode).place(x=70,y=100)
def EnglishMatch():
Score.set(0)
TiMu = tk.StringVar()
root_7 = Toplevel(); root_7.title('英语竞赛'); root_7.geometry('300x400'); root_7.resizable(width=False, height=False)
CiHui = {'学生':'student','汽车':'car','苹果':'apple','学校':'school',
'父亲':'father','自行车':'bike','单词':'word','篮球':'basketball',
'老师':'teacher','中国':'China','食物':'food','老虎':'tiger',
'柠檬':'lemon','西瓜':'watermelon','雨伞':'umbrella'}
TiMuKu = ['学生','汽车','苹果','学校','父亲','自行车','单词','篮球','老师','中国','食物','老虎','柠檬','西瓜','雨伞']
Label(root_7,textvariable=TiMu,font=('宋体',12)).place(x=85,y=40); Label(root_7,text='的英文是?',font=('宋体',12)).place(x=140,y=40); Label(root_7,textvariable=Score,font=('宋体',12,'bold')).place(x=260,y=0); Label(root_7,text='得分:',font=('宋体',12,'bold')).place(x=210,y=0)
Label(root_7,text='注意:回车可以直接确定哦')
TiMu.set(TiMuKu[random.randint(0,14)])
HuiDa = Entry(root_7,width=12)
HuiDa.place(x=100,y=60)
def QueDing(event):
if (HuiDa.get()) == (CiHui[TiMu.get()]):
Score.set(Score.get()+1)
YingYuWinTime.set(YingYuWinTime.get()+1)
else:
Score.set(Score.get()-1)
YingYuLoseTime.set(YingYuLoseTime.get()+1)
TiMu.set(TiMuKu[random.randint(0,14)])
HuiDa.delete(0, END)
def TuiChu():
JingYan.set(JingYan.get()+Score.get())
root_7.destroy()
root_7.protocol("WM_DELETE_WINDOW", TuiChu)#检测到关闭窗口事件时执行TuiChu函数
HuiDa.bind("<Return>", QueDing)#按回车的时候执行QueDing
Button(root_7,text='确定',font=('微软雅黑',12),command=QueDing).place(x=93,y=250); Button(root_7,text='退出',font=('微软雅黑',12),command=TuiChu).place(x=139,y=250)
root_7.mainloop()
def JiSuanQi():
class App:
def __init__(self, root_2):
self.root_2 = root_2
self.initWidgets()
self.hi = None
def initWidgets(self):
# 创建一个输入组件
self.show = Label(root_2,relief=SUNKEN, font=('Courier New', 24),
width=23, bg='white', anchor=W)
# 对该输入组件使用Pack布局,放在容器顶部
self.show.pack(side=TOP, pady=10)
p = Frame(self.root_2)
p.pack(side=TOP)
# 定义字符串的元组
names = ("+", "1" , "2" , "3" , "↺"
,"-", "4" , "5" , "6" , "**" , "*", "7" , "8"
, "9", "//", "/" , "." , "0" , "%", "=")
# 遍 历字符串元组
for i in range(len(names)):
# 创建Button,将Button放入p组件中
b = Button(p, text=names[i], font=('Verdana', 20), width=5)
b.grid(row=i // 5, column=i % 5)
# 为鼠标左键的单击事件绑定事件处理方法
b.bind('<Button-1>', self.click)
# 为鼠标左键的双击事件绑定事件处理方法
if b['text'] == '↺': b.bind('<Button-1>', self.clean)
# 定义一个记录输入数字次数的变量
self.i = 0
def click(self, event):
# 如果用户单击的是数字键或点号
if(event.widget['text'] in ('0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '.')):
# 判断self.i是否为0,0的话清空show['text']的值
if self.i == 0 :
self.show['text'] = ''
self.show['text'] = self.show['text'] + event.widget['text']
self.i = self.i + 1
print(self.i)
# 如果用户单击了运算符
elif(event.widget['text'] in ('+', '-', '*', '/', '%', '**', '//')):
# 把输入的数字与输入的字符相结合,组成一个数喵算式
self.show['text'] = self.show['text'] + event.widget['text']
elif(event.widget['text'] == '=' and self.show['text'] is not None):
# 赋值给self.hi
self.hi = self.show['text']
# 其实这一步可以不要,主要作用是在调试时可以在后台看输入的数据
print(self.hi)
# 使用eval函数计算表达式的值
self.show['text'] = str(eval(self.hi))
self.hi = None
self.i = 0
# 点击↺(恢复)按钮时,程序清空计算结果、将表达式设为None
def clean(self, event):
self.hi = None
self.show['text'] = ''
root_2 = Tk()
root_2.title("Watch Dog beta 3")
App(root_2)
root_2.mainloop()
def Read_Changelogs():
pass
def Settings():
root_8=Toplevel(); root_8.title('设置')
def DuQu():
JingYan.set(Info_Manager_RP.Read('Settings',2))
ShuXueWinTime.set(Info_Manager_RP.Read('Settings',3))
ShuXueLoseTime.set(Info_Manager_RP.Read('Settings',4))
YingYuWinTime.set(Info_Manager_RP.Read('Settings',5))
YingYuLoseTime.set(Info_Manager_RP.Read('Settings',6))
Name.set(Info_Manager_RP.Read('Settings',7))
messagebox.askokcancel(title='Success!',message='读取成功')
def GeRen():
root_9=Toplevel(); root_9.title('个人信息'); root_9.geometry('300x300'); root_9.resizable(width=False,height=False)
Label(root_9,text='姓名:',font=('宋体',14,'bold')).place(x=150,y=20); Label(root_9,text='等级:',font=('宋体',14,'bold')).place(x=150,y=50); Label(root_9,text='数学竞赛答对次数:',font=('宋体',14,'bold')).place(x=30,y=80); Label(root_9,text='数学竞赛答错次数:',font=('宋体',14,'bold')).place(x=30,y=110); Label(root_9,text='英语竞赛答对次数:',font=('宋体',14,'bold')).place(x=30,y=140); Label(root_9,text='英语竞赛答错次数:',font=('宋体',14,'bold')).place(x=30,y=170)
Label(root_9,textvariable=Name,font=('宋体',14,'bold')).place(x=200,y=20); Label(root_9,textvariable=JingYan,font=('宋体',14,'bold')).place(x=200,y=50)
Label(root_9,textvariable=ShuXueWinTime,font=('宋体',14,'bold')).place(x=200,y=80); Label(root_9,textvariable=ShuXueLoseTime,font=('宋体',14,'bold')).place(x=200,y=110); Label(root_9,textvariable=YingYuWinTime,font=('宋体',14,'bold')).place(x=200,y=140); Label(root_9,textvariable=YingYuLoseTime,font=('宋体',14,'bold')).place(x=200,y=170)
def Quit_MainWindow():
Info_Manager_RP.Write('Settings',str(ShuXueWinTime.get()),3,'write')
Info_Manager_RP.Write('Settings',str(ShuXueLoseTime.get()),4,'write')
Info_Manager_RP.Write('Settings',str(YingYuWinTime.get()),5,'write')
Info_Manager_RP.Write('Settings',str(YingYuLoseTime.get()),6,'write')
Info_Manager_RP.Write('Settings',str(JingYan.get()),2,'write')
root_3.destroy()
root_3.protocol("WM_DELETE_WINDOW", Quit_MainWindow)#检测到关闭窗口事件时执行TuiChu函数
c; Image_2 = tk.PhotoImage(file = 'Image\Math_Match.gif'); Image_3 = tk.PhotoImage(file = 'Image\Cop chasing thief.png'); Image_4 = tk.PhotoImage(file = 'Image\Pencil.gif'); Image_5 = tk.PhotoImage(file = 'Image\y_kx_b.gif'); Image_6 = tk.PhotoImage(file = 'Image\decode.gif'); Image_7 = tk.PhotoImage(file = 'Image\Change Logs.gif'); Image_8 = tk.PhotoImage(file='Image\Settings.gif'); Image_9 = tk.PhotoImage(file='Image\English.gif'); Image_10 = tk.PhotoImage(file='Image\Personal_Message.gif')
ShuXueJingSai= tk.Button(root_3, width=95, height=95, command=Turn_On_ZhiShiJingSai, image=Image_2).place(x=0,y=250)
JiSuanQi = tk.Button(root_3, width=95, height=95, command=JiSuanQi, image=Image_1).place(x=100,y=250)
JingChaZhuaXiaoTou = tk.Button(root_3, width=95, height=95, command=JingChaZhuaXiaoTou, image=Image_3).place(x=200,y=250)
Drawing = tk.Button(root_3, width=95, height=95, command=Drawing, image=Image_4).place(x=300,y=250)
y_kx_b = tk.Button(root_3, width=95, height=95, image=Image_5, command=y_kx_b).place(x=400,y=250)
decode = tk.Button(root_3, width=95, height=95, image=Image_6, command=String_processing).place(x=500,y=250)
Changelogs = tk.Button(root_3,width=95, height=95, image=Image_7, command=Read_Changelogs).place(x=0,y=150)
Settings = tk.Button(root_3,width=95,height=95,image=Image_8, command=Settings).place(x=100,y=150)
YingyYuJingSai = tk.Button(root_3,width=95,height=95,image=Image_9, command=EnglishMatch).place(x=200,y=150)
GeRen = tk.Button(root_3,width=95,height=95,image=Image_10,command=GeRen).place(x=300,y=150)
DuQu = tk.Button(root_3,width=8,height=1,text='读取个人信息',command=DuQu).place(x=0,y=0)
root_3.mainloop()
def AutoLogin():
if (var2.get()==1):
Info_Manager_RP.Write('Settings','AutoLogin = True',0,'Write')
if (var2.get()==0):
Info_Manager_RP.Write('Settings','AutoLogin = False',0,'Write')
def DengLu(): #登录处理方法
global NewUser,NewPasw,User,Pasw
User = UserInput.get()
Pasw = PaswInput.get()
if (var1.get()==1):
try:
NewUser = Info_Manager_RP.Read('User Save',0)
NewPasw = Info_Manager_RP.Read('User Save',1)
except:
tkinter.messagebox.showerror(title=('Wrong!'),message='读取失败,也许是路径错误或者记事本的问题,')
if User==NewUser:
if Pasw==NewPasw:
tkinter.messagebox.askokcancel(title=('Watch Dog Pass'),message='登录成功!欢迎您,新用户')
Info_Manager_RP.Write('Latest Login',User,0,'Write')
Info_Manager_RP.Write('Latest Login',Pasw,1,'Write')
startcode()
else:
tkinter.messagebox.showerror(title=('Watch Dog UnPass'),message='账号或密码错误')
else:
tkinter.messagebox.showerror(title=('Watch Dog UnPass'),message='账号或密码错误')
def QingKong():
UserInput.delete(0, END)
PaswInput.delete(0, END)
def ZhuCe():
import tkinter as ZhuCe
root = ZhuCe.Tk()
root.title('注册程序')
root.geometry("300x200")
root.resizable(width=False, height=False)
On_Hit = False
def NewZhuCe():
NewUser=str(NewUserInput.get())
NewPasw=str(NewPaswInput.get())
if (len(NewUser))<6:
tkinter.messagebox.showerror(title=('Wrong!'),message='新账号小于6位')
elif (len(NewPasw))<8:
tkinter.messagebox.showerror(title=('Wrong!'),message='新密码小于8位')
else:
Info_Manager_RP.Write('User_Save',NewUser,0,'Write')
Info_Manager_RP.Write('User_Save',NewPasw,1,'Write')
tkinter.messagebox.askokcancel(title=('Watch Dog Working'),message='账号已注册完毕并保存在本地')
NewUserInput = tk.Entry(root)#这个不能改成一行,改成一行会无法正常get
NewUserInput.place(x=90,y=40)
NewPaswInput = tk.Entry(root)#这个不能改成一行,改成一行会无法正常get
NewPaswInput.place(x=90,y=60)
aZhuCe = tk.Button(root,text="注册", width=17,height=2, command=NewZhuCe).place(x=80,y=110)
TSForZC1 = Label(root,text='输入新账号').place(x=25,y=40)
TSForZC2 = Label(root,text='输入新密码').place(x=25,y=60)
TSForZC4 = Label(root,text='账号注册 beta 2.0').place(x=75,y=10)
def ReadBeforeCheck():
if (var1.get()==1):
Info_Manager_RP.Write('Settings',"ReadBeforeCheck = True",1,'Write')
else:
Info_Manager_RP.Write('Settings',"ReadBeforeCheck = False",1,'Write')
Deng_lu = tk.Button(window, text="登录", width=17, height=2, command=DengLu).place(x=80,y=75)
QingKong = tk.Button(window, text="一键清空", width=6, height=2, command=QingKong).place(x=27,y=75)
ZhuCe = tk.Button(window, text="注册", width=2, height=2, command=ZhuCe).place(x=208,y=75)
c1 = tk.Checkbutton(window, text='是否登录时读取本地账号文件',
variable=var1,
onvalue=1, # 勾选中该项时,把1放入var1
offvalue=0, # 不勾选中该项时,把0放入var1
command=ReadBeforeCheck
).place(x=40,y=130)
c2 = tk.Checkbutton(window, text='是否下次进入益学系统时自动用本地账号登录',
variable=var2,
onvalue=1, #与上面一样,勾选该项时,把1返回到var2中
offvalue=0, #勾选该项时,把0返回到var2中
command=AutoLogin,#命令为:AutoLogin这个函数
).place(x=40,y=160) #定义放置的xy坐标
AutoLoginOrNot=Info_Manager_RP.Read('Settings',0)
ReadBeforeCheckOrNot=Info_Manager_RP.Read('Settings',1)
if AutoLoginOrNot == 'AutoLogin = True':
var2.set(1)
User_Saved = Info_Manager_RP.Read('Latest Login',0)
Pasw_Saved = Info_Manager_RP.Read('Latest Login',1)
User_Save = Info_Manager_RP.Read('User Save',0)
Pasw_Save = Info_Manager_RP.Read('User Save',1)
if User_Saved == User_Save:
if Pasw_Saved == Pasw_Save:
startcode()
else:
tkinter.messagebox.showerror(title=('AutoLogin Failed'),message='自动登录失败,请检查是否注册过并且登录过该账号')
if ReadBeforeCheckOrNot == 'ReadBeforeCheck = True':
var1.set(1)
window.mainloop()
#import Info_Manager_RP 的源代码如下!!
def Write(Which_File,Message,num_line,mode):
global File
global f#将f设为全局变量
lines=[]#新建一个名为"lines"的列表
if Which_File == 'Settings':
f = open(r'./\File Save\Settings.txt','r')
elif Which_File == 'Latest Login':
f = open(r'./\File Save\Latest Login.txt','r')
else:
f = open(r'./\File Save\User Save.txt','r')
try:
for line in f:
lines.append(line)
except:
print("错误,可能是指定文件中没有任何信息,请尝试随意加些信息进去再重启程序")
f.close()#关闭文件
lines[num_line] = '\n'#将指定的行数内容清空为回车
lines.insert(num_line,Message) #在指定行数插入内容,注:因为上一条代码把他改为了回车,这里就自带回车了
s=''.join(lines)#将修改好的内容加入到名为s的空字符串中
if Which_File == 'Settings':
f = open(r'./\File Save\Settings.txt','w')
elif Which_File == 'Latest Login':
f = open(r'./\File Save\Latest Login.txt','w')
else:
f = open(r'./\File Save\User Save.txt','w')
f.write(s)#将修改后的内容(s)写入文件中
f.close()#关闭文件
del lines[:] #清空列表
print('Write Success!') #提示已成功写入
def Read(Which_File,num_line):
global File
global f#将f设为全局变量
Var = None
lines=[]#新建一个名为"lines"的列表
if Which_File == 'Settings':
f = open(r'./\File Save\Settings.txt','r')
elif Which_File == 'Latest Login':
f = open(r'./\File Save\Latest Login.txt','r')
elif Which_File == 'Change Logs':
f = open(r'./\File Save\Change Logs.log')
else:
f = open(r'./\File Save\User Save.txt','r')
try:#异常处理,尝试打开文件
for line in f: #把文件内容循环读取到列表中
lines.append(line)#每次循环就读取文件到列表中
except:#异常处理,如果发生错误执行以下代码
print('错误,可能是指定文件没有任何信息,请尝试随意加些信息进去再重启程序')#异常处理的打印提醒
f.close()#关闭文件
Var = (lines[num_line])
Var = Var.replace("\n","")
print('Read Success!')
return Var
#import Auto_Q 的源代码如下:
def Auto_SuSuan_Q():
import random
a,b=random.randint(1,50),random.randint(1,50)
mode_count=['+','-','*','//']
mode = mode_count[random.randint(0,3)]
title = (str(a)+mode+str(b))
AutoQ_list = []
AutoQ_list.append(title+'=?')
AutoQ_list.append(eval(title))
Correct_Answer = AutoQ_list[1]
Wrong_Answer = [Correct_Answer+1,Correct_Answer-1,Correct_Answer+10,Correct_Answer-10,Correct_Answer+100,Correct_Answer-100]
Times,c = 0,0
while len(AutoQ_list)<6:
RandomNum1=random.randint(0,5)
if Times==0:
WhereIsCA=random.randint(0,3)
if WhereIsCA == Times:
if c==1:
continue
AutoQ_list.append(Correct_Answer)
c,Times=1,Times+1
continue
if (AutoQ_list.count(Wrong_Answer[RandomNum1]))==1:
continue
AutoQ_list.append(Wrong_Answer[RandomNum1])
Times=Times+1
return AutoQ_list
#附注:图片请进行自行下载,并对其转成相应的格式,如有问题请在评论区说明!!!
#版权所有,转载请通知作者并经过同意!!!!!!!!
小麦做的面包图片哪里下imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E5%86%B7%E6%BC%A0.gif"alt="emotion_编程猫_冷漠"
点赞0
评论