self.label_5 = tk.Checkbutton(self.master, text="I agree to the", bg='white', width=14,font=("Arial", 8), command= activator)
self.label_5.place(x=112, y=410)
self.button_2 = tk.Button(text='Proceed', width=20, bg='white', state = tk.DISABLED, bd=1,
highlightbackground='black', font=("Arial", 10)).place(x=208, y = 512)
def activator(button):
if (self.button_2 ['state'] == tk.DISABLED):
self.button_2 ['state'] = tk.NORMAL
else:
self.button_2['state'] = tk.DISABLED
我想在选中checkbutton后启用“继续”按钮,但我似乎无法找到它
您必须对代码进行以下更改:
activator
的函数作为self.activator
引用给Button
(button_2
)的函数时,必须将其作为command
引用李>activator
的函数的parameter
名为button
更改为self
李>Button
(button_2
)和Checkbutton
(label_5
)的部分移动到新行。就像我在下面的代码中所做的那样。这样做的原因是pack
、grid
和place
总是return
{button_2
和label_5
,值None
将存储在该小部件中李>以下是更正后的代码:
相关问题 更多 >
编程相关推荐