问题描述
我在 tkinter 中使用单选按钮,我可以很好地选择它们,但是当鼠标悬停在其中一个选项上时,它会被选中,而无需我实际单击鼠标左键.我已经研究过将单选按钮的状态更改为禁用,但显然我无法选择禁用的选项,而且我还使用了取消选择和选择方法,它们不会阻止鼠标选择当它悬停在它上面时的选项.有没有办法在我用鼠标点击它之前停止鼠标选择选项?
I'm using Radiobuttons in tkinter and I can select them fine but when the mouse hovers over one of the options it gets selected without me actually clicking the left button on the mouse. I've looked at changing the state of the Radiobutton to disabled but obviously then I wouldn't be able to select the option that is disabled and I've also used the deselect and select method and they don't stop the mouse from selecting the option when it's hovering over it. Is there a way to stop the mouse selecting the option before I click it by using my mouse?
谢谢
代码如下:
var1 = IntVar()
self.u1r1 = Radiobutton(self, text = 'Passed', value = 1, variable = var1)
self.u1r1.grid(row = 0, column = 0, sticky = W)
self.u1r2 = Radiobutton(self, text = 'Not Passed', value = 2, variable = var1)
self.u1r2.grid(row = 0, column = 0, sticky = W, padx = 60)
self.u1r3 = Radiobutton(self, text = 'Waiting', value = 3, variable = var1)
self.u1r3.grid(row = 0, column = 0, sticky = W, padx = 145)
推荐答案
试试把var1改成self.var1,这样变量对象就不会得到垃圾了-收集.
Try changing var1 to self.var1, so that the variable object doesn't get garbage-collected.
这篇关于tkinter 单选按钮在鼠标悬停在它上面时被选中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)