Question

I made a gtk app with Ubuntu quickly tool.But I have encountered a few problems with the window close button(the one in the top left of the window).So here's the thing: I want my app to close in the system tray ,so I write the code in a method ,create a button on my window and connect the "clicked" signal to my method.Everything is working as it should.Now I want my window close button to do the same thing.When i look up on the code written by quickly i found this method:

 def on_destroy(self, widget, data=None):
    # Clean up code for saving application state should be added here.
    Gtk.main_quit()

So instead of Gtk.main_quit() I called my handler for the button I deployed on my window.The thing now is that my app is hiding on the system tray but when i want to unhide it there is no window,although I can see the process of my app is alive. I want to say that when I use the button i created I can see my app when I unhide it ,so it's quite obvious that when I press the system close button there's more than one signal.

So my question is what other signals are called when I close my window from system button?And where is the place quickly implements the handler for the other signals?

Thank for your time!

Was it helpful?

Solution

Your window is "destroy". Connecting to that signal allows you to run some code, but, your window is still destroyed. If you're aren't breaking out of the main loop with Gtk.main_quit() then your app is still running. To re-display the window you would need to recreate it.

Another option is to instead connect a callback function to the "delete-event" of the window. In this signal handler if you return True then the window will not be destroyed. In other words, you could hide the window and return True and then re-show the window later. If you return False from this signal handler then the window will continue to be destroyed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top