gtk popup window question

Wouter van Marle wouterm at
Wed Mar 5 05:55:08 CET 2003


Thanks for the advices, I am going to try this out.

And it is not that I got nothing on dir(), just nothing useful. Got a few
dozen options, of which some useful (like run(), set_transient_for(), and


"John Hunter" <jdhunter at> wrote in message
news:mailman.1046789407.6040.python-list at
> >>>>> "Wouter" == Wouter van Marle <wouterm at>
>     Wouter> Hi all!  For my application I am trying to write a simple
>     Wouter> module to do the following:
>     Wouter> - open a popup window (usually error, or info) with only
>     Wouter> an OK button. I made such a window in Glade, it is a
>     Wouter> GtkMessageDialog (hope I am correct...  can't use news at
>     Wouter> home where I do my programming due to wacky server).  -
>     Wouter> change it for error, information, ... (there are five or
>     Wouter> six of these options) - change the text
>     Wouter> Even a dir() on the object didn't help me out!
>     Wouter> What to do?  There is no settext() option, or anything
>     Wouter> similar.
> You don't really need to design a message dialog in glade, because
> there is nothing to design.  gtk.MessageDialog is already designed,
> you just need to supply the parameters.  The message text is defined
> at construction
> Try this (for pygtk-2)
> import gtk
> dialog = gtk.MessageDialog(
>     parent         = None,
>     flags          = gtk.DIALOG_DESTROY_WITH_PARENT,
>     type           = gtk.MESSAGE_INFO,
>     buttons        = gtk.BUTTONS_OK,
>     message_format = "Your message here")
> dialog.set_title('Error!')
> dialog.connect('response', lambda dialog, response: dialog.destroy())
> gtk.mainloop()
> If you use this code from within some widget, you may want to set the
> parent to the calling widget, which will automatically
> set_transient_for for you.
> However, that dir on the object returned nothing is suspicious.
> MessageDialog inherits from Dialog has many many methods.  If you do
> dir(dialog) in the example above, you will see them.  In glade, if you
> call on a nonexistent widget, it will return
> None.  Is it possible you are working with None here?
> John Hunter

More information about the Python-list mailing list