"Rob Hodges" <[EMAIL PROTECTED]> writes:

> > This is just about it.  I wanted non-modal dialog boxes, so I changed
> > file_open_box() to file_open_box(modal=FALSE), and added a print so
> > you can see what is going on.
> 
> Non-modal dialogs are good, but if you let users open two of the same
> dialog it's just confusing.  I would suggest (as someone else did a
> while back when discussing the naughtiness of modality) to use a
> widget.set_sensitive(FALSE) on the button widget that pops up the
> dialog [so that they can't pop up another one, but can still use the
> rest of the app], and set_sensitive(TRUE) when they close the dialog.
> Then you neither have to make the dialog modal, nor worry about what's
> getting pushed to this or that stack (the behaviour of which it's
> probably not advisable to rely on).

An alternative is to have store a reference to the dialog in a global
variable or an instance variable and check that variable before creating
the dialog. If the dialog already exists, just make sure it's
deiconified and raised otherwise create a new dialog.

In this setup it's important to connect to the destroy signal of the
dialog so you can set the variable to None.

This approach has the advantage that you can bind the same callback to
several widgets, e.g. a button and a menu item, at once and the function
doesn't even have to know to which widgets it's bound.

-- 
Bernhard Herzog   | Sketch, a drawing program for Unix
[EMAIL PROTECTED]  | http://sketch.sourceforge.net/
-
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]

Reply via email to