I can have a script that calls a window, but when I try to raise a dialogue with parent = None, I get:
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
What parent can I map this this to? It seems I can map it to a dummy parent, but will this cause things to break and people to die?
Code from http://python-gtk-3-tutorial.readthedocs.io/en/latest/dialogs.html#messagedialog where it is called from a parent window... but I want to be able to pop this up as I'm running through a terminal script.
Edit: Some poking around (and also provide by an answer below) yielded that using Gtk.Window() as the first argument below (instead of none) does get rid of the message...
def on_question():
dialog = Gtk.MessageDialog(None, 0, Gtk.MessageType.QUESTION,
Gtk.ButtonsType.YES_NO, "This is an QUESTION MessageDialog")
dialog.format_secondary_text(
"And this is the secondary text that explains things.")
response = dialog.run()
if response == Gtk.ResponseType.YES:
print("QUESTION dialog closed by clicking YES button")
elif response == Gtk.ResponseType.NO:
print("QUESTION dialog closed by clicking NO button")
dialog.destroy()
I will made the above comment an answer. You may have a w = Gtk.Window() somewhere in your code (it may be inside function body) and pass that w to on_question:
def on_question(parent=None):
dialog = Gtk.MessageDialog(parent, 0, Gtk.MessageType.QUESTION,
Gtk.ButtonsType.YES_NO, "This is an QUESTION MessageDialog")
....
w = Gtk.Window()
on_question(w)
or
def on_question():
dialog = Gtk.MessageDialog(Gtk.Window(), 0, Gtk.MessageType.QUESTION,
Gtk.ButtonsType.YES_NO, "This is an QUESTION MessageDialog")
The Gtk-message it's gone, if that is the only problem.