Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 带字典的Tkinter复选框_Python_Dictionary_Checkbox_Tkinter - Fatal编程技术网

Python 带字典的Tkinter复选框

Python 带字典的Tkinter复选框,python,dictionary,checkbox,tkinter,Python,Dictionary,Checkbox,Tkinter,新问题: 我正在尝试创建一个Tkinter GUI,其中复选框更改字典中的值 出于某种原因,当我点击任何一个复选框时,所有其他复选框也会切换为活动和非活动。我做错了什么 from Tkinter import * class test(object): def __init__(self, root, **kwargs): self.frame = root self.frame.minsize(860, 265) self.dic_processlist

新问题:

我正在尝试创建一个Tkinter GUI,其中复选框更改字典中的值

出于某种原因,当我点击任何一个复选框时,所有其他复选框也会切换为活动和非活动。我做错了什么

from Tkinter import *

class test(object):

  def __init__(self, root, **kwargs):
     self.frame = root
     self.frame.minsize(860, 265)
     self.dic_processlist = {'a':0, 'b':0, 'c':0, 'd':0, 'e':0}

     self.chk1 = Checkbutton(text = "a", variable=self.dic_processlist['a'])
     self.chk1.grid(row=6, column=1, sticky="w")
     self.chk2 = Checkbutton(text = "b", variable=self.dic_processlist['b'])
     self.chk2.grid(row=6, column=2, sticky="w")
     self.chk3 = Checkbutton(text = "c", variable=self.dic_processlist['c'])
     self.chk3.grid(row=6, column=3, sticky="w")

if __name__ == "__main__":
   root = Tk()
   app = test(root)
   root.mainloop()
尝试使用而不是普通整数

def __init__(self, root, **kwargs):
    self.frame = root
    self.frame.minsize(860, 265)
    self.dic_processlist = {letter: IntVar() for letter in "abcde"}

非常感谢。这正是我所需要的。