Hi Johann, 

On Wed, Mar 22, 2000 at 12:05:47PM -0800, Johann Hibschman wrote:
 
> Thanks for replying.

No problem.

> I was wondering more how the python interpreter handles multiple entry
> points.  That's not clear, so I'll try to give an example.

I don't know where you see multiple entry points - it's recursion not
concurrency.

> [...]
> Choose open twice.  Then select files in the two dialog boxes.  If you
> choose a file in the first dialog box, and then in the second, the
> first returns None, while the second returns what the first should
> have returned.  If you answer the boxes in "stack order", second then
> first, everything works fine.

This problem does not lie in PyGTK itself but in the Code from GtkExtra.
From the object initializer of _FileSelection:

        if modal:
                grab_add(self)
        self.cancel_button.connect('clicked', self.quit)
        self.ok_button.connect('clicked', self.ok_cb)
        self.ret = None

So far so good - but what happens in self.quit and self.ok_cb? Simple.
In ok_cb self.ret is set to the return value. Both callbacks end up 
destroying the dialog and, here lies the problem, terminating the mainloop.
file_sel_box creates a new mainloop, so this is not the problem. But if 
you have to dialogs (which I would not want to do with this interface) 
you end up with the following stack:

 + outer mainloop (started from main script)
 \-+ inner mainloop (started from first dialog)
   \-+ innerst mainloop (started from second dialog)

The problem is: If you now work with the first window, the result is stored
in the right fileselection object but if you close the window the wrong
mainloop (the one belonging to the other window) is terminated returning
the right result (there was nothing selected in that box).

If you now work with the other window the result is stored in the second
file selection object but that value was already returned. When you quit
the second window the result of the first dialog is returned because it 
belongs to this invocation of the mainloop.

I know I did not explain it very well. Sorry, but I am not as capable in 
english as in programming languages. Please look at the GtkExtra code
and try to follow what I said to understand this.

> That's because you're creating modal boxes.  I'd like to do non-modal
> boxes.  It seems to let me (I still don't quite understand how), but I
> can't make sense of the results I'm getting.

Don't use that convenience routines from GtkExtra then. They can't really
handle inmodality.

> [...] 
> Yep.  If I call Open1, then Open2, but answer the dialog from Open1
> first, the return value goes to create_dialog_2.  Boy, this is
> confusing.

Ah, I see you already followed what's going on?

> I haven't played with the packages much myself, but they let you
> implement continuations, which should get around this weirdness.  You
> simply package up a continuation and hand it off to the dialog box.

The problem is that GTK is not thread safe so it will not help here.

HTH

    Torsten

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

PGP signature

Reply via email to