我正在使用 tkinter 编写脚本,但发生了一些奇怪的事情。
我有两个单选按钮:
way=False
RadioButton0=Radiobutton(root,text="From",variable=way,value=False)
RadioButton1=Radiobutton(root,text="To",variable=way,value=True)
RadioButton0.grid(column=0,row=2)
RadioButton1.grid(column=1,row=2)
和一个文本输入字段:
entryValue=0
entryField=Entry(root,textvariable=entryValue)
entryField.grid(column=0,row=4)
当我0在输入字段中输入时,RadioButton0自动选择,当我输入时1,RadioButton1被选择并且对于任何其他值,它们都被选择...反之亦然:当我选择时RadioButton0,输入字段更改为0,当我选择时RadioButton1,输入字段更改为1... 此外,entryValue后来被视为0. 变量way只能由单选按钮修改...
为什么会这样?我在做不该做的事吗?我该如何解决?