waiting on a callback with PyGTK

Rob Hodges s323140 at student.uq.edu.au
Wed Aug 18 09:45:32 EDT 1999


Hello Python gurus,

Please forgive me if this is a really dumb question!

I've been playing around with PyGTK and have a little program that
pops up a dialog with a text entry in it.  When the user hits Enter in
the text entry, a callback grabs the contents of the entry.

Now here's my problem: I want the program to sit there doing
essentially nothing until the callback returns.  I thought I'd be able
to do this by inspecting the variable that the callback sets to the
contents of the entry: Initialise the variable to an empty string or
None, pop up the dialog and then inspect the variable (member 'text' of
class instance 'dialog') like this:

while not dialog.text:
        time.sleep(0.02)

But then the dialog just never comes up, even though the inspection
comes after the creation and show()ing of the dialog.  What is
happening here?  And more to the point, how do I get around it?  I'm
sure this must be a very common thing to do and I'm missing something
basic.

-Rob





More information about the Python-list mailing list