【发布时间】:2020-03-13 18:21:37
【问题描述】:
我正在尝试创建一个显示时间的 tkinter 页面,并且应该不断更新。我试过了:
from tkinter.font import *
import time
def SetTime():
global time_date
time_date = time.strftime("%H:%M")
InfoTime.set(time_date)
Main = Tk()
Main.geometry("1600x1200")
Main.title("Time")
FontStyle = Font(family = "Times New Roman", size = 48)
InfoTime = StringVar()
TitleText = Label(Main,textvariable = InfoTime,font = FontStyle).pack()
while True:
SetTime()
但是,运行
While True: 线路和运行
SetTime()
由于某种原因,不断地阻止 tkinter 页面(主)打开。这对我的许多 tkinter 项目来说都是一个问题。
请注意,我在 IDLE 中运行 python 3.7.2。 谢谢。
【问题讨论】:
标签: loops tkinter python-3.7