Thanks everyone for all of the help.  I almost have this working.

Everything is written in a class.  I think I have that right, but that remains 
to be seen. :-)

I can create the login window and get all of the controls on it.  My function 
gets called to validate the information in the fields when the user presses the 
button.  

the function called however, can't seem to be able to get the items from the 
fields.  I get the error like list.get(ACTIVE) doesn't have a function for get. 
 (list was defined as a listbox.)  the same is true for the other form fields. 
I opted to use the root window and implement a frame in it for the login.  Once 
the login data has been validated, i can destroy the frame and reuse the 
window.  This may or may not work ;-)  I am a python newbie, biting off a big 
complicated chunk 

The class is defined:
class Login:
        def __init__(self, parent):
                self.window = parent

When I show the class instance, everything is displayed.  My verification code,

        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
Traceback (most recent call last):
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py",
 line 1410, in __call__
    return self.func(*args)
  File "z.py", line 229, in verifyLogin
    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)

What have I got messed up?  I have poked around the net but I can't find 
anything meaningful to me.

Thanks again


Chris Hare
ch...@labr.net
http://www.labr.net

On Nov 1, 2011, at 7:50 PM, Alan Gauld wrote:

> On 01/11/11 21:28, Chris Hare wrote:
>> 
>> Good feedback Alan, thanks.
>> 
>> I wasn't using the root window to hold the login form, although I
>> suppose I could. I guess where I am stuck is the login to control
>> displaying the login window, and hiding it to display the actual
>> application window once the user has authenticated.
> 
> Thats what your command function does. So when the button is pressed your 
> event handler authenticates the user details, if valid it closes the Login 
> and shows the main window(which could be root...)
> In pseudocode:
> 
> 
> def doLogin(self):
>    userid = idField.get()
>    passwd = pwField.get()
>    if self.validateUser(userid,passwd):
>        root.show()
>        self.window.hide()
>    else:
>        self.beep()   # or whatever warning message you want
>        self.logError("User authentication failed for " + userid)
>        self.idField.clear()
>        self.pwField.clear()
> 
> Then in creating the button you pass that as the command handler:
> 
> btnLogin = Button(self.window, text="Login", command=doLogin)
> 
> Now, when the user hits the button the doLogin function will be called.
> If the login is ok we show the main window and hide the login dialog.
> If the entry is invalid we beep, clear the fields for a retry and log an 
> error. We could also add a count so after, say, three attempts we close the 
> app.
> 
> HTH
> -- 
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to