检查
我正在用python中的tkinter编写一个简单的GUI。我需要两个不同的组合。但是,当我在第一个Combobox上选择一个值时,由于某种原因,它将该值写入第二个和Viceversa,就好像它们是链接一样。我该如何链接它们?这是我的代码。
subjects = Combobox(frame_answer,text = ("Arial",20), width = 60,height =40)
subjects.grid(row = 20, column = 50)
questions = Combobox(frame_answer,text = ("Arial",20), width = 60,height = 40)
questions.grid(row = 40, column = 50)
questions["values"] = ["Select","Question1","Queston2","Question3"]
subjects["values"] = ["Select","Math","Science","Spanish"]
您将text
参数传递给了两个ComboBox。我相信您的意思是font
。
subjects = ttk.Combobox(root,font = ("Arial",20), width = 60,height =40)
questions = ttk.Combobox(root,font = ("Arial",20), width = 60,height = 40)
通过使用text
,您实际上为两个Combobox创建了一个常见的textvariable
。您可以致电subjects.config()
和questions.config()
。