[Tutor] login window using Tk
Alan Gauld
alan.gauld at btinternet.com
Wed Nov 2 11:02:28 CET 2011
On 02/11/11 05:05, Chris Hare wrote:
> def verifyLogin(self):
> farmid = list.get(ACTIVE)
> userid = login_userid.get()
> login_passwd = login_passwd.get()
>
> gets called, but I get the error
>
> Exception in Tkinter callback
> farmid = list.get(ACTIVE)
> AttributeError: type object 'list' has no attribute 'get'
>
> When the frame controls were added, list is defined as
>
> list = Listbox(frame)
names defined in functions are local to that function. They can't be
seen outside of the function. So...
To be able to access the controls you need to add themas instance
attributes to your class. so you should use
self.list = Listbox(....
and
farmid = self.list.get(....
What you are seeing is Python looking for something called list in your
methods namespace and not finding it. It can't see anything global
either so it picks up the built-in list() type.
HTH
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list