python - Enabling or disabling checkbox with conditionals -


in code i'm trying disable hi box when no checked , enable when yes checked. attempt in changed function. when running code , checking yes box hi still fine , when checking yes yes box get:

exception in tkinter callback traceback (most recent call last): file "c:\users\ahmed\appdata\local\programs\python\python35-32\lib\idlelib\run.py", line 119, in main seq, request = rpc.request_queue.get(block=true, timeout=0.05) file "c:\users\ahmed\appdata\local\programs\python\python35-32\lib\queue.py", line 172, in raise empty queue.empty

during handling of above exception, exception occurred:

traceback (most recent call last): file "c:\users\ahmed\appdata\local\programs\python\python35-32\lib\tkinter__init__.py", line 1550, in call return self.func(*args) file "c:\users\ahmed\desktop\no_yes.py", line 13, in changed c3.config(state=enable) nameerror: name 'enable' not defined

it might me using idle , not importing right thing (i have nothing modified or installed idle plain comes python site) im thinking way attempt enable or disable checkboxes in changed function. want know enable , disable checkboxes upon meeting proper requirements(disable if no selected, enable if yes selected.)

#import tkinter make gui tkinter import * tkinter import ttk  def changed(*args):     value = b1.get()     value2 = b2.get()     value3 = b3.get()     print (b3.get()=="1")     if b1.get()==1:         c3.config(state=disabled)     elif b2.get() == "1" , (b1.get() == "1") == false:         c3.config(state=enable)     elif b3.get() != "1":         result.set("")     elif b3.get() == "1":         result.set("hi!") #sets title , creates gui root = tk() root.title("form")  #configures column , row settings , sets padding mainframe = ttk.frame(root, padding="3 3 12 12") mainframe.grid(column=0, row=0, sticky=(n, w, e, s)) mainframe.columnconfigure(0, weight=1) mainframe.rowconfigure(0, weight=1)  b1 = stringvar() c1 = ttk.checkbutton(mainframe, text='no',          command=changed, variable=b1) c1.grid(column=1, row=1, sticky=(w, e))  b2 = stringvar() c2 = ttk.checkbutton(mainframe, text='yes',          command=changed, variable=b2) c2.grid(column=2, row=1, sticky=(w, e))  b3 = stringvar() c3 = ttk.checkbutton(mainframe, text='hi',          command=changed, variable=b3) c3.grid(column=2, row=2, sticky=(w, e))  result = stringvar() ttk.label(mainframe, textvariable=result).grid(column=1, row=2, sticky=(w)) 

alright, disabling , enabling goes so:

button.state(['disabled'])            # set disabled flag, disabling button button.state(['!disabled'])           # clear disabled flag button.instate(['disabled'])          # return true if button disabled, else false button.instate(['!disabled'])         # return true if button not disabled, else false button.instate(['!disabled'], cmd)    # execute 'cmd' if button not disabled 

Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -