-1

So, I try to get the values from inputs (3) and pass them on to a function on a button click.

This is what I have now:

Label(self.master, text="Name").grid(row=0, sticky=W)
    Label(self.master, text="Username").grid(row=1, sticky=W)
    Label(self.master, text="Email").grid(row=2, sticky=W)

    self.e_name = Entry(self.master).grid(row=0, column=1)
    self.e_username = Entry(self.master).grid(row=1, column=1)
    self.e_email = Entry(self.master).grid(row=2, column=1)

    Button(self.master, text="Login", command=self.login_client).grid(row=3, column=1, sticky=E)

And the function:

def login_client(self):
    print(self.e_name.get())

Now, I get this error: AttributeError: 'NoneType' object has no attribute 'get'...

The full code of the file can be found here: https://gist.github.com/RosiersRobin/343c0194fde2e8e3184f24cb5aecac28

I just want the input from the user to be given in the function login_client

Robin
  • 1,567
  • 3
  • 25
  • 67

1 Answers1

2

Your problem is the .grid() call. grid returns None, so self.e_name will be None. Just change these lines to these ones:

self.e_name = Entry(self.master)
self.e_name.grid(row=0, column=1)
self.e_username = Entry(self.master)
self.e_username.grid(row=1, column=1)
self.e_email = Entry(self.master)
self.e_email.grid(row=2, column=1)
progmatico
  • 4,714
  • 1
  • 16
  • 27
MegaIng
  • 7,361
  • 1
  • 22
  • 35