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.


    Missing Turtle functionality?

    Pythonista
    turtle help
    4
    9
    2643
    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.
    • SkiNoCap
      SkiNoCap last edited by

      I have been starting to use turtle in my coding class, and one of the commands they demand I use is wn.clearscreen(), something that Pythonista says does not exist. First of all, why does it not exist? Am I missing a library or is the library out of date or something else? Secondly, how can I configure things to allow this argument? Any help would be appreciated, thank you.

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

        @SkiNoCap there is a turtle.clear

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

          Search in doc

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

            @cvp I see that the Pythonista module is not the same as the standard one (including mouse and keyboard interaction which is what S.exitonclick() would be) but S.clear() doesn't do what I want it to, which is to close the UI. I guess there is no alternative though, I'll just have to remember to include S.exitonclick() when I turn in my assignments. Thank you!

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

              try:
                  S.exitonclick()
              except AttributeError:
                  pass  # Workaround for Pythonista
              SkiNoCap 1 Reply Last reply Reply Quote 0
              • SkiNoCap
                SkiNoCap @ccc last edited by ccc

                @ccc said:

                S

                I might be typing it in incorrectly, but when I do I get a syntax error with "except AttributeError". Here's what I typed:

                try:
                    wn.exitonclick()
                except AttributeError:
                    pass
                
                cvp 1 Reply Last reply Reply Quote 0
                • cvp
                  cvp @SkiNoCap last edited by ccc

                  @SkiNoCap you forgot the "try: " line

                  try:
                      wn.exitonclick()
                  except AttributeError: # <--- the : was forgotten 
                      pass  # Workaround for Pythonista
                  
                  SkiNoCap 1 Reply Last reply Reply Quote 0
                  • SkiNoCap
                    SkiNoCap @cvp last edited by

                    @cvp alright so it works without an error, but when I click (tap) on the window it doesn't show any sort of a response (now thinking about it, probably because it's an exception, not running the code - correct me if I'm wrong). Is the effect the same as .exitonclick() when run through another IDE like IDLE? Away from my PC and can't try it right now.

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

                      I'll just point out that the turtle module in pythonista is written in pure python (plus the canvas or ui module, I forget which), so can be edited to provide whatever missing functionality you need... Although that may be more effort than you really want!

                      For instance, see
                      https://forum.omz-software.com/topic/5014/shape-method-for-turtle-py

                      The cpython turtle module is mostly NOT tkinter -- in theory it shouldn't be too hard to just strip out the tkinter drawing methods with ui.path drawing methods.

                      If you are trying required to submit programs that work in a particular environment, you probably should make sure that you run your final checks in that
                      environment -- get yourself a free shell account if you don't have a desktop/laptop. Sagecell also is a way that you can run code in a more standard environment (there are some threads on pythonista and sagecell with a wrench script that lets you run a script edited in pythonista on a sagecell server)

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