-1

Here's the code

from tkinter import*

win = Tk()

win.title('My application')

e = Entry(win).pack()

def click():

    label = Label(win, text = 
            "Hello" + 
            e.get()).pack()

button = Button(win, text = 
        'Enter your name', 
        command = 
        'click').pack()

win.mainloop()

When I enter a name and click the button I created I end up with an error like, " Attribute Error: 'NoneType' object has no attribute 'get' ".

Can anybody please tell me why am I keep getting this Attribute error and how can I fix this? By the way, I'm a beginner who is trying to learn the basics.

Delrius Euphoria
  • 14,910
  • 3
  • 15
  • 46

1 Answers1

0

Change e = Entry(win).pack() to

e = Entry(win)
e.pack()

This is because e = Entry(win).pack() returns None and hence the error.

Hope this helped you.

Cheers

Delrius Euphoria
  • 14,910
  • 3
  • 15
  • 46