gtk popup window question
John Hunter
jdhunter at ace.bsd.uchicago.edu
Tue Mar 4 09:48:41 EST 2003
>>>>> "Wouter" == Wouter van Marle <wouterm at spammers-unite-here.com> writes:
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())
dialog.show()
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 gtk.glade.XML.get_widget 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