I have an need to have an initially Disabled button which is later enabled on an event. I have a rather large application that is working except I cannot get the state change to the button. Please don't tell me I need to completely resturcture the code. This is a strip out of all of the code leaving the salient structures I am using. ReadPort actually gets called from an 'after' but it simulated by the button press, here.
I have read all the helps on this subject and tried the answers. The Python statements and the errors each produces is in this complete application that fails in all attempts to change the button state. Please let me know how to fix this.
#!/usr/bin/python 3
from tkinter import *
def ReadPort():
global VSM_Button
# AttributeError: 'NoneType' object has no attribute 'config'
## VSM_Button.config(state="normal")
# AttributeError: 'NoneType' object has no attribute 'configure'
## VSM_Button.configure(state="normal")
# TypeError: 'NoneType' object does not support item assignment
## VSM_Button['state'] = 'normal'
# AttributeError: 'NoneType' object has no attribute 'configure'
## VSM_Button.configure(state=NORMAL)
# ??? How do I set the button state to 'normal' ?
pass
class Application:
def __init__(self, master):
#global VSM_Button # seems unnecessary. Same errors in or out.
frame = Frame(master)
frame.pack()
Button(frame, text='Press Me', width = 10, command=ReadPort).pack()
VSM_Button = Button(frame, text='Disabled', width = 10, state = DISABLED).pack()
pass # end def __init__
pass # end class Application
root = Tk()
root.wm_title('Button')
app = Application(master=root)
root.mainloop()