I have built an app with bluetooth running in a seperate thread. Now when I close the app via the UI (with the close button in the top left corner), the app still runs and I need to send 'CTRL-C' via the [x] button in Pythonista.
Is there a way to send 'CTRL-C' via the UI close button in the title bar?
I want to call
except KeyboardInterrupt:
cb.reset()
when the close button in the title bar is tapped.
I have tried making the main View a customView and then using
class MainView(ui.View):
def will_close(self):
print('Closing')
cb.reset()
sys.exit(0)
but while the function gets called, I still have to hit the [x] button in order to stop the script execution.
Only to be clear: I do not want to close Pythonista, I only want to stop the script from running, when I hit the close button in the UI and return to the console/editor.