Gtk.MessageDialog window parameter problems

Posted by William Culver on Ask Ubuntu See other posts from Ask Ubuntu or by William Culver
Published on 2012-07-05T15:05:11Z Indexed on 2012/07/05 15:23 UTC
Read the original article Hit count: 283

Filed under:
|
|

I'm in a deeply nested class (which inherits from Gtk.Box) and I need to get a reference to the GtkWindow I'm in to pass to a call to Gtk.MessageDialog() yet I cant seem to find a reference to it.

I have tried self.props.window as well as self.get_parent_window() with no avail.

Everything I try to do leads to the following error:

TypeError: Expected Gtk.Window, but got GObjectMeta

Code snippet is as follows:

def on_tb_del_clicked(self,widget):
    question = _("Are you sure you want to do this?")
    win = self.get_parent_window() 
    dialog = Gtk.MessageDialog(win,0,Gtk.MessageType.QUESTION,
                                   Gtk.ButtonsType.YES_NO,question) # <<Exception 
    response = dialog.run()

Please help :)

© Ask Ubuntu or respective owner

Related posts about python

Related posts about quickly