Pythoncard mental block

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jlocc@fau.edu

    #1

    Pythoncard mental block

    Hi!!

    I am working on a school project and I decided to use PythonCard and
    wxPython for my GUI development. I need a password window that will
    block unwanted users from the system. I got the pop-up password
    question to work...

    def on_openBackgrou nd(self, event):

    result = dialog.textEntr yDialog(self,
    'System',
    'Please enter your password: ',
    '')

    ......but I don't exactly remember how to check if the entered password
    is correct. Say I hard code the password to be 'hello', then how would
    I check if this was the input or if it wasn't???

    Sorry, I've got a mental block....I'm using the latest
    everything....t hankssss!!

  • Steven D'Aprano

    #2
    Re: Pythoncard mental block

    On Fri, 07 Oct 2005 10:25:24 -0700, jlocc wrote:
    [color=blue]
    > Hi!!
    >
    > I am working on a school project and I decided to use PythonCard and
    > wxPython for my GUI development. I need a password window that will
    > block unwanted users from the system. I got the pop-up password
    > question to work...[/color]

    I haven't seen any replies to this, so even though I don't actually
    use Pythoncard I'll take a wild shot in the dark.

    [color=blue]
    > def on_openBackgrou nd(self, event):
    >
    > result = dialog.textEntr yDialog(self,
    > 'System',
    > 'Please enter your password: ',
    > '')
    >
    > .....but I don't exactly remember how to check if the entered password
    > is correct. Say I hard code the password to be 'hello', then how would I
    > check if this was the input or if it wasn't???[/color]

    Start with looking at result and seeing what is in it. If it is the input
    string, then just say

    if result == 'hello':
    # do whatever you need to
    else:
    # put up a dialog saying 'Password does not match!'

    But I'm guessing from the syntax that the dialog instance itself is stored
    in result, so perhaps you need to look at some attribute of result:

    if result.userInpu t == "hello": # or something like that?

    Lastly, I might not have used Pythoncard, but years ago I used to use
    Hypercard rather a lot. In Hypercard, the password dialog would use a
    one-way hash function to encrypt the typed response into a large integer
    value. I assume Pythoncard is designed to do the same thing as Hypercard.

    So, in rusty Hypercard syntax with Python-style comments:

    # retrieve the numeric value of the password
    put field "hidden password" into userpassword
    # put up a dialog asking the user to enter a password
    ask password "Please enter your password:"
    if the result is "" then:
    # the user clicked Cancel, so just abort or go away or something
    go home
    else if the result is userpassword:
    # we have a match!
    go to card "Secret card"
    else:
    # password doesn't match
    go to card "Password failure"


    Hope this is of some help to you, and I haven't led you too far astray.


    --
    Steven.

    Comment

    Working...