May-18-2023, 12:53 PM
Hi,
When I click the button I expect the entry to be populated. Instead I get the error "AttributeError: 'GUI' object has no attribute 'genPassText'".
What am I missing?
When I click the button I expect the entry to be populated. Instead I get the error "AttributeError: 'GUI' object has no attribute 'genPassText'".
What am I missing?
from tkinter import * class GUI: def DoSomething(self): self.genPassText.delete(0, END) self.genPassText.insert(0,'Hello World') def __init__(self): # root window self.root = Tk() self.root.title("Demo") self.root.geometry("800x280") self.root.resizable(width=FALSE, height=FALSE) # pass length information genPassButton = Button(self.root, text = "Generate Password", command=self.DoSomething).grid(row=8, column=0, padx=5, pady=5) genPassText = Entry(self.root, width=80, bd=3, font=('Bold')).grid(row=8, column=1, padx=5, pady=5) if __name__ == '__main__': mainwindow = GUI() mainloop()Thanks,