I’m new using tkinter and I’ve run into a following issue.
In the init method of my class APP I’m creating a couple a label and a button with the handler that should change the label text
def __init(self):
....
self.label = ttk.Label(frame, text='some text')
self.button = tk.Button(frame, command='lambda: self.change())
def change():
if (hasattr(App, 'label'):
self.label.configure(text='Other text')
and I’m getting the error
App.label.configure(text=cn)
AttributeError: 'NoneType' object has no attribute 'configure'
Why is the label element losing its object?
I expect the label attribute to retain the assigned value but it does not seem to do that
New contributor
Aaron Stromas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.