1
我想创建一个简单的GUI,可以输入一些值。在之前和之后的标签以及用于启动脚本的按钮。tkinter创建标签并动态地输入
我用的是这样的:
w = Label(master, text="weight:")
w.grid(sticky=E)
w = Label(root, text="bodyfathydrationmuscle:bones")
w.grid(sticky=E)
w = Label(root, text="hydration:")
w.grid(sticky=E)
其确定,但我想这样做动态。另外当我将w用于所有的entrys时,我只能使用w.get一次。但我需要我的所有数据;-)
我在想:
def create_widgets(self):
L=["weight","bodyfat","hydration","muscle","bones"]
LV=[]
for index in range(len(L)):
print(index)
print(L[index])
("Entry"+L[index])= Entry(root)
("Entry"+L[index]).grid(sticky=E)
("Label"+L[index])=Label(root, text=L[index])
("Label"+L[index]).grid(row=index, column=1)
以后要拨打:
var_weight=Entryweight.get()
var_bodyfat=Entrybodyfat.get()
等。我怎样才能使它工作?