Hi Johann, 

On Tue, Mar 21, 2000 at 01:22:23PM -0800, Johann Hibschman wrote:

> Could anyone explain the structure of the event loop to me?  Or at
> least point me at the right documentation?

The event loop is quite simple. Once you have created all the GUI objects
you call the main loop. This loop will monitor all event sources and 
deliver them as signals to the target. Those signal functions run without
intervention by the main loop. As soon as they return the main loop 
continues monitoring the event sources.

> While that box is sitting there, I can access the menu again and
> create another dialog box, which will pop up happily.  If I reply to
> the new box, then reply to the old box, everything works as expected.
> However, if I reply to the old box first, then the new one, the reply
> to the new box is ignored.  So there's a stack buried in there
> somewhere.

Sorry, but I can't reconstruct what you are doing from this. I tried 
to write a program as you describe but I did not run into a problem.

This is my code:

from gtk import *
from GtkExtra import *

def quit(obj):
        mainquit()

def create_dialog(obj):
        file_open_box()

main = GtkWindow(WINDOW_TOPLEVEL)
menu = MenuFactory()
menu.add_entries([
  ("File/Open...", "<control>O", create_dialog), 
  ("File/Quit", "<control>Q", quit)])
main.add_accel_group(menu.accelerator)
main.add(menu)
main.connect("destroy", mainquit)
main.show_all()
mainloop()

> Why doesn't the existance of the first dialog box tie up the python
> interpreter, preventing the second box from being created?  How does

It does here...

> the gtk event-loop get control back from python, if python is waiting
> for the result of the dialog?  Where are the continuations being
> stored?  How should I think of this, if I want to make sense of it?

Simple - in the file_open_box code a second incarnation of the mainloop
is created which is running until the file selector is closed. A grab
is used to prevent interaction with other windows during that time.
When you click on OK or Cancel, mainquit is called and the inner mainloop
is terminated returning control to the caller of file_open_box.

> (By the way, this seems like something which could be done in a very
> flashy way with a combination of Stackless Python and microthreads.

Stackless Python? Microthreads? Sound like nice buzzwords to me (and 
nothing more).

HTH

    Torsten

-- 
Torsten Landschoff           Bluehorn@IRC               <[EMAIL PROTECTED]>
           Debian Developer and Quality Assurance Committee Member

PGP signature

Reply via email to