简体   繁体   English

Python中的动态检查按钮

[英]Dynamic Checkbuttons in Python

I have to implement 5 to 6 checkbuttons next to each other at run time. 我必须在运行时彼此相邻实现5到6个检查按钮。 The checkboxes are generating but when i deselect any one of them, the rest get deselected too. 复选框正在生成,但是当我取消选择其中任何一个时,其余复选框也会被取消选择。 Also, another thing if i want is , if the text attribute of a checkbutton is repeated, it should line up at the same place as where it was and not create a new checkbutton. 另外,如果我想要的另一件事是,如果重复执行checkbutton的text属性,则它应该与原来的位置对齐,而不创建新的checkbutton。

the only code i have for the checkbutton is this 我对checkbutton唯一的代码是

option2 = Checkbutton(self.controls,text = name,
variable = self.variable,command lambda:display_temperature(self.variable,name))

option2.pack(side = 'left', anchor = 'sw', pady = 10, padx = 10) self.controls.pack() option2.pack(side ='left',anchor ='sw',pady = 10,padx = 10)self.controls.pack()

如果所有复选按钮具有相同的名称,并且都附加到相同的变量中,则python将无法区分它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM