Commit 385afc8e by BellCodeEditor

save project

parent b08ff02a
Showing with 26 additions and 8 deletions
import tkinter import tkinter
import json
def register():
name = e1.get()
password1 = e2.get()
password2 = e3.get()
if name=='':
print('用户名为空!')
elif password2!=password1:
print('两次密码不一样')
elif password1=='':
print('密码不能为空!')
else:
x = {name:password2}
x = json.dumps(x, ensure_ascii=False)
with open("1.txt","a", encoding='utf-8') as f:
f.write(x)
with open('1.txt', 'r', encoding='utf-8') as f:
content = f.read() #文件读取操作
# 建立窗口对象 # 建立窗口对象
root = tkinter.Tk() root = tkinter.Tk()
...@@ -19,21 +37,21 @@ e3.place(x = 140,y = 200) ...@@ -19,21 +37,21 @@ e3.place(x = 140,y = 200)
# 注册界面上的文字标签 # 注册界面上的文字标签
lab = tkinter.Label(root, text='您好!请填写注册信息', font=('宋体', 15), lab = tkinter.Label(root, text='您好!请填写注册信息', font=('宋体', 15),
fg="black",width=40, height=2,bg="green") fg="white",width=40, height=2,bg="purple")
lab.place(x=0,y=0) lab.place(x=0,y=0)
# 在输入框前展示文字标签:用户名:、密 码:、确认密码: # 在输入框前展示文字标签:用户名:、密 码:、确认密码:
l0 = tkinter.Label(root,text = '您好!请填写注册信息',font = ('宋体',15), l0 = tkinter.Label(root,text = '您好!请填写注册信息',font = ('宋体',15),
fg = 'white',width = 40,height = 2,bg = 'green') fg = 'white',width = 40,height = 2,bg = 'purple')
l0.place(x = 0,y = 0) l0.place(x = 0,y = 0)
l1 = tkinter.Label(root,text = '用户名:',font = ('宋体',12), l1 = tkinter.Label(root,text = '用户名:',font = ('宋体',12),
fg = 'red') fg = 'lightblue')
l1.place(x = 60,y = 80) l1.place(x = 60,y = 80)
l2 = tkinter.Label(root,text = '密码:',font = ('宋体',12), l2 = tkinter.Label(root,text = '密码:',font = ('宋体',12),
fg = 'red') fg = 'lightblue')
l2.place(x = 60,y = 140) l2.place(x = 60,y = 140)
l3 = tkinter.Label(root,text = '确认密码:',font = ('宋体',12), l3 = tkinter.Label(root,text = '确认密码:',font = ('宋体',12),
fg = 'red') fg = 'lightblue')
l3.place(x = 60,y = 200) l3.place(x = 50,y = 200)
b = tkinter.Button(root,text = '提交',bg = 'lightpink',width = 15,command = register)
# 保持窗口监听,进入消息循环 b.place(x = 150,y = 250)
root.mainloop() root.mainloop()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment