Reputation: 2510
I have a pygtk app running on windows and linux. The main GUI has close down function that is called from the delete event (when user clicks the X button on the window) or from the menu via FILE->QUIT
The code looks like this
def close_down(self):
self.hide_gui()
#do some cleanup stuff here, close down a log file etc...
gtk.main_quit()
def on_close_down_activate(self, widget): # From menu
self.close_down()
print("Closed")
def on_main_gui_delete_event(self, window, event): # From window X button
self.close_down()
print("Closed")
But when the user clicks the X button on the window, the word "Closed" is printed to the cmd line, but the app hangs and never returns control the the cmd line unless I kill python via the task manager. If the user selects Quit from the file menu the app prints the word "Closed" and returns control to the cmd line.
On Linux it acts as expected. Is gtk on windows keeping some thing going?
Upvotes: 0
Views: 292
Reputation: 6898
To close an application in PyGTK, you actually need two lines of code, not just one. My guess is that, in Linux, the window is closing, but the process is not. In Windows, nothing is closing.
To fix this, just add the following line below "gtk.main_quit()"
return False
The reason for this code is that, in pyGTK, you can leverage this line for creating "Are you sure you want to quit?" dialogs. If the line read "return True", the program would not close at all.
Upvotes: 1