Commit 2c3211a7 by BellCodeEditor

auto save

parent 145fe74a
Showing with 141 additions and 5 deletions
import tkinter import tkinter
from tkinter import messagebox
import json
def login_to_reg(): # 登录界面转注册界面 with open('user.txt','r',encoding='utf-8')as f:
pass info = f.read()
users = json.loads(info)
def login_to_reg(): # 登录界面转注册界面
app_login.root.destroy()
global app_reg
app_reg = My_register()
app_reg.show()
def reg_to_login(): # 注册界面转登录界面 def reg_to_login(): # 注册界面转登录界面
pass app_reg.root.destroy()
global app_login
app_login = My_login()
app_login.show()
def register(): # 注册验证 def register(): # 注册验证
pass name,password1,password2 = app_reg.get_input()
if name == '' or password1 == "" or password2 == "" :
messagebox.showwarning("警告","请填写完整的注册资料")
elif name in users:
messagebox.showwarning("错误","用户名已存在")
elif password1 != password2:
messagebox.showwarning("错误","两次密码不一致")
else:
users[name] = password1
content = json.dumps(users)
with open('uset.txt','w',encoding='utf-8')as file:
file.write(content)
messagebox.showinfo("成功","注册成功!")
login_show()
def login(): # 登录验证 def login(): # 登录验证
pass pass
......
{"admin": "123456", "aaa": "11223"}
\ No newline at end of file
##import library
##import library
from tkinter import *
import time
#from playsound import playsound
## display window
root = Tk()
root.geometry('400x300')
root.resizable(0,0)
root.config(bg ='blanched almond')
root.title('TechVidvan - Countdown Clock And Timer')
Label(root, text = 'Countdown Clock and Timer' , font = 'arial 20 bold', bg ='papaya whip').pack()
#display current time#######################
Label(root, font ='arial 15 bold', text = 'current time :', bg = 'papaya whip').place(x = 40 ,y = 70)
####fun to display current time
def clock():
clock_time = time.strftime('%H:%M:%S %p')
curr_time.config(text = clock_time)
curr_time.after(1000,clock)
curr_time =Label(root, font ='arial 15 bold', text = '', fg = 'gray25' ,bg ='papaya whip')
curr_time.place(x = 190 , y = 70)
clock()
#######################timer countdown##########
#storing seconds
sec = StringVar()
Entry(root, textvariable = sec, width = 2, font = 'arial 12').place(x=250, y=155)
sec.set('00')
#storing minutes
mins= StringVar()
Entry(root, textvariable = mins, width =2, font = 'arial 12').place(x=225, y=155)
mins.set('00')
# storing hours
hrs= StringVar()
Entry(root, textvariable = hrs, width =2, font = 'arial 12').place(x=200, y=155)
hrs.set('00')
##########fun to start countdown
def countdown():
times = int(hrs.get())*3600+ int(mins.get())*60 + int(sec.get())
while times > -1:
minute,second = (times // 60 , times % 60)
hour = 0
if minute > 60:
hour , minute = (minute // 60 , minute % 60)
sec.set(second)
mins.set(minute)
hrs.set(hour)
root.update()
time.sleep(1)
if(times == 0):
#playsound('Loud_Alarm_Clock_Buzzer.mp3')
sec.set('00')
mins.set('00')
hrs.set('00')
times -= 1
Label(root, font ='arial 15 bold', text = 'set the time', bg ='papaya whip').place(x = 40 ,y = 150)
Button(root, text='START', bd ='5', command = countdown, bg = 'antique white', font = 'arial 10 bold').place(x=150, y=210)
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