[pygtk] prevent gtk.Dialog from closing

Walter Leibbrandt walter at translate.org.za
Tue Sep 9 19:48:12 WST 2008


Tasos Latsas wrote:
> Hello,
> I have a dialog box which prompts the user for some input with an entry
> box. I want to be able to check the user input before returning to the
> main window and show another popup window with a message,
>  e.g. ("you left the field empty, press cancel button or fill it etc")
> and then prevent the dialog from closing.
>
> I tried to intercept the delete-event but didn't help also i didn't find
> something similar at the faq
> Is this possible with a gtk.dialog or i have to use a gtk.window?
>   
 From 
https://stage.maemo.org/svn/maemo/projects/haf/tags/python-sdk/2.0final/gazpacho-hildon/hildonwidgets/libs.py 
<http://www.google.com/codesearch/url?hl=en&ct=rpc&url=https://stage.maemo.org/svn/maemo/projects/haf/tags/python-sdk/2.0final/gazpacho-hildon/hildonwidgets/libs.py&usg=AFQjCNFsGtCs_UJH8zEP6FmVOGc808Eunw>:

dialog.window.set_functions(gtk.gdk.FUNC_CLOSE) # see http://www.pygtk.org/docs/pygtk/gdk-constants.html#gdk-wm-function-constants
dialog.window.set_decorations(gtk.gdk.DECOR_ALL) # see http://www.pygtk.org/docs/pygtk/gdk-constants.html#gdk-wm-decoration-constants


With the right parameters you should get the effect you're looking for.

But I would like to urge you to reconsider altering this. From a UI 
design point-of-view, closing a dialog should be enough of a response 
from the user (ie. the same as if he hit "Cancel"). Make sure that you 
want to break this convention before doing so.

Regards,

Walter


-- 
Walter Leibbrandt                  http://translate.org.za/blogs/walter
Software Developer                                  +27 12 460 1095 (w)
Translate.org.za

Recent blogs:
* The first official release of Spelt
http://www.translate.org.za/blogs/walter/en/content/first-official-release-spelt
* Auto-completion and auto-correction for Gtk+ widgets
* Gtk+ Tip of the Day: Modifying the subject of an event being processed




More information about the pygtk mailing list