這是我的代碼和子功能被執行,但它沒有得到mainloop()。 如果我註釋掉「update_Lux(labelLuxValue)」,窗口就會出現。 我想不通爲什麼:(Tkinter:窗口無法打開
from Tkinter import *
def update_Lux(label):
label.config(text = str(dev.calcLux()))
label.after(100, update_Lux(label))
def update_CT():
labelCTValue.config(text = str(dev.calcCT()))
labelCTValue.after(100, update_CT())
box = Tk()
box.title('TCS3490')
box.geometry('200x180')
labelLux = Label(master=box, text='Lux=')
labelLux.place(x=5, y=5, width=60, height=30)
labelCT = Label(master=box, text='CT=')
labelCT.place(x=5, y=30, width=60, height=30)
labelLuxValue = Label(master=box)
labelLuxValue.place(x=50, y=5, width=100, height=30)
labelCTValue = Label(master=box)
labelCTValue.place(x=50, y=30, width=100, height=30)
update_Lux(labelLuxValue)
box.mainloop()
可能calcLux()會花費太多時間?如果你將100增加到2000或更多,會發生什麼? – paddyg