I have created a two-window app with Glade and pygobject. I have a window with an open-window-button that opens the second window. The second window has a close button. When I click the close-button it prints something to the terminal and triggers a ".hide_on_delete()" function, which closes the second window.
When I click the open-window-button again it opens the window again with a simple ".show()". And I can do this as often as I want to.
However there's a problem when I close the second window with the "x" in the upper-right corner instead of with the close-button I created. In glade I set up the "destroy" event and gave it the correct function name. When I close the second window via the "x" It even prints out "Clicked on the X button" and closes the second window. But when I open it up again I just get a black square with no window decoration and when I click on it I get this error message:
(main.py:11083): Gtk-CRITICAL **: 21:37:50.904: gtk_widget_get_window: assertion 'GTK_IS_WIDGET (widget)' failed
(main.py:11083): Gtk-CRITICAL **: 21:37:50.905: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed
(main.py:11083): Gtk-CRITICAL **: 21:37:50.905: gtk_widget_get_window: assertion 'GTK_IS_WIDGET (widget)' failed
(main.py:11083): Gtk-CRITICAL **: 21:37:50.905: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed
(main.py:11083): Gtk-CRITICAL **: 21:37:50.905: gtk_widget_get_settings: assertion 'GTK_IS_WIDGET (widget)' failed
/usr/lib/python3.6/site-packages/gi/overrides/Gtk.py:1612: Warning: g_object_get: assertion 'G_IS_OBJECT (object)' failed
return _Gtk_main(*args, **kwargs)
(main.py:11083): Gtk-CRITICAL **: 21:37:50.905: gtk_widget_get_window: assertion 'GTK_IS_WIDGET (widget)' failed
(main.py:11083): Gtk-CRITICAL **: 21:37:50.905: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed
(main.py:11083): Gtk-CRITICAL **: 21:37:50.977: gtk_widget_get_window: assertion 'GTK_IS_WIDGET (widget)' failed
(main.py:11083): Gtk-CRITICAL **: 21:37:50.977: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed
(main.py:11083): Gtk-CRITICAL **: 21:37:50.977: gtk_widget_get_window: assertion 'GTK_IS_WIDGET (widget)' failed
(main.py:11083): Gtk-CRITICAL **: 21:37:50.977: gtk_widget_get_window: assertion 'GTK_IS_WIDGET (widget)' failed
Here are my functions:
def on_second_window_destroy(self, *args):
print("x Button clicked")
app.builder.get_object("second_window").hide_on_delete()
def on_new_window_button_clicked(self, *args):
app.builder.get_object("second_window").show()
def on_close_button_clicked(self, *args):
print("close Button clicked")
app.builder.get_object("second_window").hide_on_delete()
The close button and the "x" button trigger the exact same function. Why does one let me reopen the window again and the other one doesn't? I really do not understand what's wrong.
Thanks so much in advance for any help!