omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    quit the script

    Pythonista
    8
    22
    24293
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • technoway
      technoway last edited by technoway

      Is there still no function or method to shutdown Pythonista from within a script?

      1 Reply Last reply Reply Quote 0
      • ccc
        ccc last edited by ccc

        I believe that @omz post above is still correct. There is no supported way to auto-shutdown Pythonista because users would perceive it unexpected behavior for an iOS app. Do you know of other iOS apps that auto-shutdown?

        Phuket2 technoway 2 Replies Last reply Reply Quote 0
        • Phuket2
          Phuket2 @ccc last edited by

          @ccc , I think it still would be nice to be able to shutdown Pythonista via code. I understand why sys.exit() should not do it. But an implicit method to do it could be a good idea, hence no misunderstanding between the language vrs a platform feature.

          1 Reply Last reply Reply Quote 0
          • JonB
            JonB last edited by

            import os
            os.abort()

            1 Reply Last reply Reply Quote 0
            • technoway
              technoway last edited by technoway

              JonB - Thanks for the reply. Unfortunately, os.abort() appears to do the same thing as os.exit(0). The app goes away, but the console window, and one other window, presumably the main Pythonista window, are running in the background and have to be closed separately.

              I'm running the latest Pythonista beta on an iPhone 6s running IOS 11.2.1

              I'm not complaining. Pythonista is great the way it is. That would be a nice feature though.

              JonB 1 Reply Last reply Reply Quote 0
              • technoway
                technoway @ccc last edited by technoway

                @ccc - I did some searching, and apparently Apple discourages calling exit(0) in objective C to close an app, because that appears similar to an app crashing.

                My issue is that when I use a shortcut URL to launch my GUI application, when I hit the home button to close the app, there are two windows to close, not just one like most (all?) other apps.

                Is there a way I can make my app so that it does not show the second window when I start the app this way?

                I am using a uiView-derived window in my app.

                cvp 1 Reply Last reply Reply Quote 0
                • cvp
                  cvp @technoway last edited by cvp

                  @technoway Hi, when we start a script from an url, Pythonista shows the last edited file as first window, while the script is initialized.
                  I've put as last edited file, a .txt file with an ascii art content, that will say a drawing (I use Mona Lisa) done with ascii characters. This solution does not really solve the problem but it shows a "pretty" window of your choice as first window.

                  	      :';t)/!||||(//L+)'(-\\/ddjWWW#######WmKK(\!(/-|J=/\\t/!-/\!_L\) 
                          |-!/(!-)\L\)/!\5(!.!LWW###################WK/|!\\\\/!;\/\T\/((\ 
                          |!'//\//(-!t\Y/\L!m#####M####################WLt\\!)\/J-//)/;t\ 
                          --/-.\.\/\.!)///m######K#######################WK!/!-( )-!,|/\ 
                          //,\--`--!-/\(q#######DD##########################L\\\\-!!//!\\
                          -.-!\'!!\-\/:W########N############################W,).'-.-/\-' 
                          !.\!-!-!`!-!W#######P|+~**@@@#######################W/,/'\-/,\7 
                          --`,-- -/.:W###*P!'          \`Z8#####################;,\\`,\,\
                          `.'.'\`-.-d##5'-           -- '-:V@##########W#########_\-!-\\-
                          `, -,.'/,G##K- '               - )7KM###################\-----/
                          - '-  --:##@;                    -!ZZ###################W! \'!- 
                           '-.`- G###|.                    `,D8K###################|/-.-/ 
                          -' ,-//###@)                      -)ZWMW##################\` _\
                          - ' .:Yd###!                     `-!(K5K##################|(/L|
                            - :\G###Z-                    ` ! -;55ZZ#################)(4) 
                           . -!W####!\                     `  ' !-tVG################XNVZ 
                             tt####@-.                        `  ')(W################D)8@ 
                             )8#####\                         .-`-/KW#################KD# 
                            ||Z####W!-              .::,\.. -,;\bZKK######8#K#########(#8 
                            KN8#####( ,:!/GG_      d4KW8ZKW#WWK#W#88#######W##########WK# 
                           )/8K###K#W#WP~~~T4(    dW##7'___L#M####MM8W###W############bM8 
                          \!48#K####8##W*###WY;   WRob+~~######*ff/\NM8###############WW# 
                          .\\KW###W#,~t' !*~!',  -M@)    `~`,),' '.`K#################@KW 
                          .'8M###### -'..j/Z''    @//-  ,,\\+\'    :|W######M###########8 
                          :\#8#K###D              \!`             !:Z8###8@#####8W#W###8M 
                          q8W5######             `!-             `-)8##################M8 
                          8WZ8#M####-             /  .          .\tK############@######ZJ 
                          #W#@K###W#|              //           \\tW@###@K##W##W###K###Wm 
                          ##8#M#8###P-            -=/,         /;D8W##############@###W## 
                          #8###M@####\-      ,   _)jJ;        -((WKK#####W####W##K######K 
                          ###W@K##K##);     `\..KW##WK       )X)KW#M##W###MW##@#W######8# 
                          #K#W####@#@@/;-     ~M####M\    ,.\\=)D8W##W###W##########8W##@ 
                          ####MW######(`\\'     PPK((.:|/!-\-/)8XN@WMK#######W##MK#@##### 
                          ##8##MK#W#@#b!--\)L_. .(ZLWbW#\'- ,-N|/KM#######W###@########W# 
                          ##KW###K#W###/-  !``~~Yff*N5f -' -.\))KK#######MK##W###M8W#W### 
                          #W###K@K######J--    .._dd/;)/- !//)NK#8W##########8########M#K 
                          ##8W#K###W#####W!.   `YY\)\\)\7(-)4dW#8#@###K#W#######8######## 
                          M####8##K#KW###W#/,       '-\\//)88W#M#@#K##M###@##M#8##@#W#8#M 
                          ZW#W#M#K##########m       -)!/LtWW#W##@#W#####KW#######W###K### 
                          K##W#####W#M#8#####KL   .-//dD##8W#K######8##########MK###W##M# 
                          tN#W##W#W#M##########bb4dKW#@##W##K####MK####8###########W##### 
                          )NM#8W##@###@##############@##@##8##K#W####M##K##K#@###8##M#### 
                          (tMM###W##M8####@####@###@#########@####8W##8W################M 
                          tNZ##K###W####@#####8###/4N##8#W##W##M#8#MK#M8#K######W######## 
                          M/K@8###M@###M##########|!t*Z#N####8##M8Z@ZZ#M###@#W#####K###W# 
                          WVd4M######@############D,\`(+KKZD#8WK#5@84VZ#WM############W## 
                          K5WM8#8W#W########8######,,-!/))ZK5@K4)@+(/XV/Z###@###W###M#### 
                          +8WN@##@K##W###W#########b.-.\!||\X(5)Z/7\\\t5/K########W###### 
                          8M8###@###@##8#########KDbt! !.-!t`(-\\!.\/.\!ZdG###W#MW###G### 
                          ~~~~~`~~~~~~~~~~~~~~~~'~` ''  ' ` ` '```
                  1 Reply Last reply Reply Quote 0
                  • JonB
                    JonB @technoway last edited by

                    @technoway os.abort() crashes the app, so when you launch it again, it is fresh. Not sure i follow what you mean about two windows? screenshot?

                    cvp 1 Reply Last reply Reply Quote 0
                    • cvp
                      cvp @JonB last edited by

                      @JonB I think he will say that when you launch a script from the exterior (url, launcher app), during some seconds, you see another "window", the last edited file, py or txt.

                      1 Reply Last reply Reply Quote 0
                      • technoway
                        technoway last edited by technoway

                        cvp - That is what I meant. When os.abort() or os._exit(0) is called, the app shuts down, the home screen shows, but, depending on the Pythonista app, there are one or two windows running in the background.

                        It's not a big deal. I can launch Pythonista again without closing these windows.

                        1 Reply Last reply Reply Quote 0
                        • Phuket2
                          Phuket2 last edited by

                          The os.abort() is not perfect. But could still help when setting up scripts on a friends device

                          1 Reply Last reply Reply Quote 0
                          • JonB
                            JonB last edited by

                            You are saying you see two windows from the home button menu? And click either of them reopens pythonista?

                            Can you slowly go through step by step what you are doing to produce this behavior? i.e are you launching pythonista normally? Or using a home screen shortcut?
                            Do you see pythonista last contents in both window? or is one of them blank?

                            A screenshot would also go a long way to understanding this.

                            Finally, do you need to actually terminate pythonista, or just return to the last app? There are some methods on UIapplication that let you suspend + return to last app.

                            technoway 1 Reply Last reply Reply Quote 0
                            • technoway
                              technoway @JonB last edited by technoway

                              @JonB - In every case described below, I am starting the application using a shortcut .

                              When my app calls os._exit(0), I see no windows. If I click the home button, I see two windows in the background.

                              I can run my application by clicking on one of the windows.

                              If I use os._exit(0), I still see two windows, and just as before, I can still restart my app by clicking on one of the windows. (It's the mostly all white (console?) window,- my application sets a black background which shows in the other window). Note, I call console.exit(), so I though I closed the console window.

                              I am also still able to reopen Pythonista using the Pythonista icon while that other window is present.

                              I must not be cleaning something up?

                              1 Reply Last reply Reply Quote 0
                              • omz
                                omz last edited by

                                @technoway The way homescreen shortcuts work is that you basically create a web app shortcut that redirects to a pythonista3://... URL. The blank "window" you see actually belongs to Safari, and its sole purpose is to launch Pythonista. It isn't technically possible to remove this from the app switcher programmatically, and unfortunately, it's not possible to implement homescreen shortcuts any other way (not involving Safari).

                                1 Reply Last reply Reply Quote 1
                                • technoway
                                  technoway last edited by

                                  @omz - Thank you for the reply. That will stop me from trying to remove something I cannot remove.

                                  1 Reply Last reply Reply Quote 0
                                  • First post
                                    Last post
                                  Powered by NodeBB Forums | Contributors