Close app from home screen button
-
Hi,
i am always getting problems to close an app from the home screen button. If i test the script in the pythonista app everything works fine and i can close the app. But if i add a button for the app on Homescreen then the mainscreen open twice and after pushing the Exit button it only close the first screen and not the pythonista app. Can someone tell me how to really close an app?
Thanks a lot.
Cu kami
def appclose(): v.close() nav.close() os._exit(0)
-
@cvp, oh my goodness, that looks cool!
-
@mikael yes sir, and even 3D FlyOver. And all that thanks to Pythonista and some marvelous modules like Gestures, WKWebView of a guy called @mikael 😂
-
Hi,
thanks a lot for all the answer. But this doesn't solve my problem. So for now i made a simple example for everyone which will show my problem. I created a python script like this:
import ui import os def close(sender): v.close() os.abort() v = ui.load_view() v.present('sheet')
and a pyui:
[ { "nodes" : [ { "nodes" : [ ], "frame" : "{{95, 162}, {80, 55}}", "class" : "Button", "attributes" : { "action" : "close", "frame" : "{{95, 217}, {80, 32}}", "title" : "Button", "uuid" : "B05F9F96-41D2-41C1-B4E1-C27F68D5CD4A", "class" : "Button", "name" : "button1", "font_size" : 15 }, "selected" : true } ], "frame" : "{{0, 0}, {270, 466}}", "class" : "View", "attributes" : { "enabled" : true, "background_color" : "RGBA(1.000000,1.000000,1.000000,1.000000)", "tint_color" : "RGBA(0.000000,0.478000,1.000000,1.000000)", "border_color" : "RGBA(0.000000,0.000000,0.000000,1.000000)", "flex" : "" }, "selected" : false } ]
With this script and UI i just add a Button on the Home screen like it is described in Pythonista.
Then i close all app on my iphone. I press the button and the App is opening twice. I press the Button in the UI and it closes. I see the normal Iphone homescren. If i now press the Home screen Button of the App (the shortcut), i only see a screen from Pythonista with a complete green background. I have to close manually from the IOS all pythonista screen and after this i can normally start the shortcut of the script again. So how can help me with this.
Thanks a lot.
cu kami
-
last edited by
-
@kami, just to rule out potential issues, can you confirm that you tried launching your script via a home screen icon that you created with the Apple Shortcuts app?
I used this simple script, called test-launch.py:
import ui, os class SuperClose(ui.View): def will_close(self): os.abort() v = SuperClose(background_color='red') v.present()
And this URL in the Shorcuts app:
pythonista3://test-launch?action=run
And the script is launched only once and Pythonista goes away when I close the view.
-
@mikael I think he uses omz' script for creating an icon on home screen (here) and in this case, tapping the icon starts twice the app.
-
HI, i will try to create an Apple Shortcut. But can someone please tell me how to write the path if the files are stored in the icloud?
Thanks a lot.
Cu kami
-
@kami see the Pythonista doc, The Pythonista URL Scheme
Add this at end of your url scheme
?root=icloud
Ex: pythonista3://my_folder/my_script?action=run&root=icloud&argv=argument
-
Hi, thanks a lot. Now with the Apple Shortcut everything works fine.
Cu kami