[Mac] Allow app close without quitting process but actually Quit on quit selection.

41 views
Skip to first unread message

Ben Platta

unread,
Apr 21, 2022, 1:00:47 PM4/21/22
to Kivy users support
My goal:

1. When the user clicks the little red exit button on the app, merely hide the window. That is, do not kill the kivy app process.
2. When a user selects Quit fron the top bar menu, here we should close the window and actually quit the process.

So in short, the red exit button should merely hide the window whereas the quit button should quit the app proper.

What I've found so far: I can bind to the on_request_close function on the Window:

Window.bind(on_request_close=self.hide_window)

where hide_window:

def hide_window(self, *args, **kwargs):
      window = args[0]
      return True

Here, I understand returning True prevents the close. However, I would like to return False when I know that it was the meny bar Quit selected that prompted the call vs. the red exit button click on the window. I did some digging on the window object to see if there was some state I could use to infer that the exit button was clicked. The closest thing seemed to be the on_cursor_enter and setting a flag. However, the little bar on the window that contains the exit button is "outside" unfortunately.

Any ideas?

Thanks in advance.

Ben


Elliot Garbus

unread,
Apr 21, 2022, 9:18:45 PM4/21/22
to kivy-...@googlegroups.com

I assume that both the quit, and clicking the “red-ball” are firing the on_request_close event.

 

While not a perfect solution, you could use a popup in the on_request close that asks the user if they want to quit or minimize.  I did something like this in an app, where if the user had not saved the file they were working with – they would be prompted to cancel (cancel the close request), save & exit (save the file and quit the app) or just exit the app.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/3f9011fd-50c5-493a-addd-3be8f49ccd4en%40googlegroups.com.

 

Ben Platta

unread,
Apr 22, 2022, 1:50:06 PM4/22/22
to Kivy users support
Thats a good idea, thanks very much Elliot.
Reply all
Reply to author
Forward
0 new messages