I am trying to create a working dialog box in Python 2.7/GTK+ 3 (PyGObject). I found an online tutorial which offered the following code...
md = Gtk.MessageDialog(window,
Gtk.DIALOG_DESTROY_WITH_PARENT,
Gtk.MESSAGE_INFO,
Gtk.BUTTONS_CLOSE,
msg)
response = md.run()
However, running this results in the error...
AttributeError: 'gi.repository.Gtk' object has no attribute 'DIALOG_DESTROY_WITH_PARENT'
I'm fairly sure this has to do with the fact that the above code worked on PyGtk (GTK 2). How do I get this working?
After a little bit of research, I found that, yes, this is due to a change in library structure from PyGTK to PyGObject. (Read the documentation for how to work with dialogs, and see line 27 of the example at that link's bookmark.)
The enumeration
Gtk.DIALOG_DESTROY_WITH_PARENTdoes not appear to exist in PyGObject, as the documentation suggests passing a0directly.Beyond that,
Gtk.MESSAGE_INFOhas been moved toGtk.MessageType.INFO, andGTK.BUTTONS_CLOSEhas been moved toGtk.ButtonsType.CLOSE.This may be bright-blazingly obvious to some, but Gtk isn't exactly famous for their documentation, so this is for anyone who might have been fighting with this for a while as I did.