im trying to program my project so that when I click the button "click it" the text "never gonna give you up" in the title is replaced with whatever text is in the text box. here's most of my code:
class MyApp:
def __init__(self, root):
root.title("never gonna give you up") #title of the window
root.geometry("1000x500") #the size of the window on launch
root.maxsize(2000,1000) #the maximum size of the window
label=Label(root,text='the text thats displayed in the window',bg="red") #creates a 'label' for the window 'root'
label.pack() #displays widget
#using dictionary syntax, one at a time
#label['text']="new label text"
#label["font"]=("Arial",30)
#using configure method
label.configure(text="never gonna give you up", font=("Comic Sans MS", 20))
self.entry_text=StringVar() #used to hold text in entry, can be bound to other widgets
entry=Entry(root, textvariable=self.entry_text) #when this changes stingvar will change as well
entry.pack() #will display widget below other widget
#label["textvariable"]=entry_text #binds label to what is typed in entry
button=Button(root, text="click it",command=self.press_button)
button.pack()
#label.configure(text="new xxx", font=("Comic Sans MS",26))
def press_button(self):
text=self.entry_text.get()
self.label_text.set(text)
whenever I click the button, it returns this error:
line 34, in press_button
self.label_text.set()
AttributeError: 'MyApp' object has no attribute 'label_text'
I've been working on this for a couple days, and I still don't know whats wrong.