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

Reply via email to