GtkDialog mapped without a transient parent

2019-01-17 09:57发布

问题:

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:

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.



回答2:

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