48

I have a GUI built in Glade (3.18) which is called by a Python 3 program (using PyGObject). I get a lot of warnings when running the program (Fedora 21) that say:

Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.

How can I fix this warning? I tried filling in the field Transient for: main_window in Glade for all the dialog windows, but the warnings still appear.

1

2 Answers 2

26

You fix this warning by giving the GtkDialog a parent to be modal to. The relevant functions are gtk_window_set_transient_for() (which sets this window to always be on top of, or transient for, another one) and optionally gtk_window_set_modal() to make it a modal dialog. This is ultimately what the various GtkDialog constructors do.

12
  • Does that mean I need to pass the main_window instance to each dialog class? If I instead use self.builder.add_objects_from_file(..."main_window") in the dialog, then I get errors, because the main_window signals are not connected (which is of course correct, because the dialog has different signals than the main window). The setting in Glade might fail because of similar reasons. The transient option is set, but on runtime, the dialog has no access to the main_window instance. Commented Apr 27, 2015 at 6:34
  • 1
    Is there any reason you can't call set_transient_for() when you show your dialog? That's what the "mapped" part means
    – andlabs
    Commented Apr 27, 2015 at 13:41
  • I probably made a silly mistake, but inserting any of those variants in the below the linked line does not help with the error message: github.com/tobias47n9e/innstereo/blob/master/innstereo/… Commented Apr 27, 2015 at 16:14
  • 2
    I just made another try, and indeed it works if I pass the main_window object (the GtkWindow) to each dialog and then use self.dialog.set_transient_for(main_window) (I used the __init__ function for that). Thanks again for your help! Commented Apr 30, 2015 at 22:22
  • 11
    My application is only dialogs, there is no "main window". What am I supposed to pass to this function?
    – Rich
    Commented May 28, 2016 at 19:40
0

Use a GtkWindow instead; and use a GtkDialog only when there is a parent window/dialog.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.