如何使用公式制作标签?每当我更改条目中的值时,它是否会自动更改标签中的值?就像excel单元格里有公式一样。以防在条目为空时它必须是不可见的(没有内容)。你知道吗
import tkinter as tk
root = tk.Tk()
ent1 = tk.Entry(root)
lab1 = tk.Label(root,text='Price')
ent2 = tk.Entry(root)
lab2 = tk.Label(root,text='Quantity')
lab3 = tk.Label(root,text='') #lab3 formula = float(ent1.get()) * int(ent2.get())
lab1.pack()
ent1.pack()
lab2.pack()
ent2.pack()
lab3.pack()
使用
trace
方法在变量更改时执行函数。你知道吗相关问题 更多 >
编程相关推荐