[Pythoncard-users] Re: Pythoncard mental block

Alex Tweedly alex at tweedly.net
Sun Oct 9 05:47:05 EDT 2005


Gregory Piñero wrote:

> The Python-Card guys are really helpful, 
> <pythoncard-users at lists.sourceforge.net 
> <mailto:pythoncard-users at lists.sourceforge.net>>, you may have to 
> register on sourceforge to get on their list.
>
> In the meantime I went ahead and cc'd them on this.  Python-Card guys, 
> make sure to cc Steven as he may not be on the list.
>
Thanks Greg.

>
>     > 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...
>
>     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.
>
>
>     >    def on_openBackground(self, event):
>     >
>     >         result = dialog.textEntryDialog(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???
>
Usually, you'll do something like ...

>             result = dialog.textEntryDialog(self, 'Enter your 
> password:', 'Password',
>                 '', wx.TE_PASSWORD)
>             if result.accepted and result.text != '':
>                 self.pwd = result.text
>             else:
>                 <do something appropriate if you don't have a password 
> to use>

Note the last parameter wx.TE_PASSWORD - this ensures that the 
characters typed are echoed as starts (or bullets, or something) so they 
can't be read by anyone overlooking the user.  [you may need to add an 
"import wx" to use this]

The Text Entry Dialog has both an "OK" and a "Cancel" button (and can be 
simply closed), so it's important to check that result.accepted is True 
before using any text entered.

The sampleLauncher of small demos and samples that comes with PythonCard 
has a an example of usage for every kind of dialog, and most of the 
components, so it can be a good source for questions like this.  Also, 
you can often find what you need by using the FindFiles utility (comes 
with PythonCard) to find examples of usage within the PythonCard samples 
subdirectory.

>     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.
>
The parallels with Hypercard aren't that strong. :-)

In this case, PythonCard is more versatile (i.e. less helpful) - it just 
returns the string entered, leaving it up to you whether to one-way hash 
it, encrypt it, use it as an MD5 key phrase, or whatever.


-- 
Alex Tweedly       http://www.tweedly.net

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20051009/ee82ac45/attachment.html>
-------------- next part --------------
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.13/123 - Release Date: 06/10/2005



More information about the Python-list mailing list