【发布时间】:2015-09-16 13:50:55
【问题描述】:
这就是代码,很大程度上来自这个问题:
How do I create multiple checkboxes from a list in a for loop in python tkinter.
from tkinter import *
root = Tk()
enable = {'jack': 0, 'john': 1}
def actright(x):
print(enable.get(x))
for machine in enable:
enable[machine] = Variable()
l = Checkbutton(root, text=machine, variable=enable[machine],
command= actright(machine))
l.pack(anchor = W)
root.mainloop()
我预计输出是:
0
1
相反的输出是:
PY_VAR0
PY_VAR1
如果没有数字前的“PY_VAR”,如何获得这些值?
【问题讨论】:
标签: python user-interface python-3.x tkinter