[Tutor] Class mind boggle

Liam Clarke cyresse at gmail.com
Fri Nov 5 05:15:33 CET 2004


Hello all, 

I have a little prog I'm writing, and I'm creating a GUI with PythonCard.
The actual functions accessed by the GUI are in a separate module.

Now, I would like to call a dialog box if needed in one of the
separate functions, if a password is wrong, get it via a nice little
pop-up.

PythonCard comes with built in basic dialogs, which are accessed like so:

result = dialog.textEntryDialog(self, 'What is your favorite
language?', 'A title'                                 , 'Python')

the self part is the parent window... OK, so I need to call the dialog
from within my GUI.

So, I've got -

gui.py

from PythonCard import model, dialog

class Main(model.background):

      def some stuff
      def some more stuff

       def getPassword(self, user):
             result = dialog.textEntryDialog(self, 'Enter Password,
'Uhoh' , 'Python')
             
app=model.application(Main)
app.mainloop()

and in function.py

             try:
                session.login(user, pwd)
             except:
                 .... 

At this point I want to call gui.Main.getPassword, pass it the
variable user, and get back a value from result.text.

Which makes my head go all squiggly. Can you tell a class method to
return values?

I've tried creating a new object of gui.Main() and calling it's
badPassword method in the except: clause like so:

except:

       wd=gui.Main()
       pwd=wd.getPassword()


No matter what I do, no dialog box opens, and I get no error messages
in my console.

Normally, I'm just calling functions from functions, and they all run
def... return, which is nice and easy to comprehend.

But, classes, they just have def... : o

So yeah, the paradigm of OOP gets me again.

Any help that can be offered is appreciated.

Regards,

Liam Clarke

'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.


More information about the Tutor mailing list