下面的代码就是我现在的代码。我还用interweb中给定的解决方案进行了尝试,比如这里Link1。在
但这对于像我这样的简单函数来说太复杂了,我希望有更“优雅”的代码。 这就是我所拥有的:
.
.
box = Tk()
box.title('TCS3490')
box.geometry('200x180')
labelLux = Label(master=box, text='Lux=')
labelLux.place(x=5, y=5, width=60, height=30)
labelLuxValue = Label(master=box, text=str(dev.calcLux()))
labelLuxValue.place(x=50, y=50, width=100, height=30)
labelLuxValue.after(10, labelLuxValue.config(text = str(dev.calcLux()))
box.mainloop()
它只在标签中放一次值,但不能再放一次。 开发工具calcLux()返回浮点值 为什么?在
代码中的问题是after行只执行一次,您需要一个递归函数:
示例见: https://mail.python.org/pipermail/tkinter-discuss/2006-April/000704.html
相关问题 更多 >
编程相关推荐