用户:
上帝之鹰查看:1 回复:1 评论:1 创建时间:2021-06-10T13:03:30
import time
from tkinter import *
import tkinter.messagebox as messagebox
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.pack()
self.createWidgets()
def createWidgets(self):
self.timeInput = Entry(self)
self.timeInput.pack()
self.alertButton = Button(self, text='start', command=self.start)
self.alertButton.pack()
def start(self):
ST = self.timeInput.get() or '1800'
ST = int(ST)
while True:
time.sleep(ST)
messagebox.showinfo('Message', "Time's up! Take a break!")
app = Application()
# 设置窗口标题:
app.master.title('preserve eyesight')
# 主消息循环:
app.mainloop()