我的第一个问题。在
我目前正在用python3.5用Tkinter编写一个GUI。在
我在我的应用程序中有一个设置框,我有单选按钮让用户更改它们。当我只有一组单选按钮时没有问题,但是当我添加第二组单选按钮时,Python认为它们都属于同一组,用户只能选择6个单选按钮中的一个(我希望用户能够总共选择两个,每组1个)。有没有办法告诉Tkkinter/Python有两组单选按钮?我用一些关键字搜索堆栈溢出,但大多数问题都是关于如何从单选按钮中获取值的,没有一个回答我的问题。在
下面是单选按钮的示例代码,可以帮助您想象情况:
import tkinter as tk
#I'm not writing things like frames or stuff, this is just to
#tell you how my radio buttons are categorized
#I want these to be separate:
s1r1=tk.Radiobutton(root,text="Red") #Set 1-Radiobutton 1
s1r2=tk.Radiobutton(root,text="Green") #Set 1-Radiobutton 2
s1r3=tk.Radiobutton(root,text="Blue") #Set 1-Radiobutton 3
#than these:
s2r1=tk.Radiobutton(root,text="1") #Set 2-Radiobutton 1
s2r2=tk.Radiobutton(root,text="2") #Set 2-Radiobutton 2
s2r3=tk.Radiobutton(root,text="3") #Set 2-Radiobutton 3
非常感谢!在
您没有将两个不同的变量绑定到按钮组。每个}相关联。在
Radiobutton
组必须与单个StringVar()
或{相关问题 更多 >
编程相关推荐