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.


    What's with canvas in Pythonista 3.

    Pythonista
    canvas pthonista 3 bug
    7
    28
    30056
    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.
    • JonB
      JonB last edited by

      you might also look at matplotlib as another portable answer. You can manipulate pixels directly, if you like, using numpy arrays, then matplotlib.image.imsave to save it, or you can show it using imshow and show(). Or, you can use the various pyplot commands for doing line drawing without resorting to pixel bashing. A little slow starting up on ios, but otherwise works pretty well.

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

        @zencuke Just to be clear, I do appreciate your feedback about things that are clearly broken of course, and I intend to fix them, it's just unlikely that the canvas module will gain a lot of new functionality in the future.

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

          @zencuke , this is a very nice demo using canvas with @omz turtle implementation. Sorry, I can't remember where I found it. But it's nice. I had saved it a few days ago. I changed a few settings though. Just can't remember where I found it.

          This is just a copy that that I downloaded, as I say I changed a few things, but not sure what. @omz maybe you can share your original link.

          my gist

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

            @omz Works for me. ;-) The nice thing about Pythonista is that I have so many choices. Thanks for that.

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

              turtle.py is (undocumented as far as i can tell) included in pythonista, at least as far back as 1.5

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

                @JonB Not quite. I actually built a version of the turtle module specifically for Pythonista 3, just a few months ago, and it is only available in Python 3 mode at the moment... The standard library turtle module is built on top of Tkinter, so I basically had to re-implement it from scratch, using ui-based drawing. What I've got so far is included in Pythonista 3, but a few things are missing, and I haven't documented it (or mentioned it in the release notes) because I'm not completely sure if I want to continue with this approach.

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

                  Hello, I wanted to check whether the old canvas library had ever been fixed or whether it is now terminally deprecated. Just found out last night that all my old graphics examples don't work anymore (neither in Pythonista 2 nor in 3) and reduced it to this crashing. After some iterations (aproximately 20 out loops) there is no further output and after s hort while a full abort of Pythonista follows.

                  # coding: utf-8
                  import canvas
                  import colorsys
                  from six.moves import range
                  
                  #this crashes Pythonista 2 and 3. canvas depracated?
                  
                  w=h=512
                  canvas.set_size(w,h)
                  
                  
                  def plot():
                     canvas.clear()
                     for x in range(1,512,2):
                        for y in range(1,512,2):
                           canvas.set_fill_color(.75,.25,.25)
                           canvas.fill_ellipse(x,y,1,1)
                  
                  1 Reply Last reply Reply Quote 0
                  • JonB
                    JonB last edited by

                    I think you might find this will make your code work, at least it did for me:

                    canvas.begin_updates()
                    plot()
                    canvas.end_updates()

                    Unless you are trying to see the individual dots appear one at a time...

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

                      Hi JonB,

                      thanks for the hint.
                      Yes, wrapping everything in begin_update/end_update works for me as well.

                      Unfortunately, I was actually trying to make the "live update" visible, i.e. seeing every dot appear.
                      If that's not required it's straight forward to use the UI module instead, but live updates are actually relatively complex to do in there. I use this for educational purposes, so having a lot of (object oriented) code around this is quite counter-productive.

                      If I wrap every fill_ellipse call into begin_update/end_update (just for fun) i get exactly the same effect as without wrapping. Seems canvas doesn't like to be overloaded with update requests.

                      1 Reply Last reply Reply Quote 0
                      • robopu
                        robopu @zencuke last edited by

                        @zencuke said:

                        @omz Thank you. That will be helpful. I experimented with several gestures but didn't hit on that one. I kept trying to pull it down by grabbing the top edge. Are the supported gestures documented anywhere? There are a few documented in the "Using Pythonista" section. I sometimes have this paranoid feeling that everyone else gets much more from Pythonista because they know all these cool features I never heard of. I need a 4 year old to beat on my iPhone. They try everything and seem to find new gestures faster than anyone else.

                        BTW: I haven't told you this lately but Pythonista is the absolutely the coolest app I have ever seen. I tell everyone who will listen how great it is. My next project is to sell my kids on it who are both learning python in other contexts. And the best part is you keep adding cool new features. I was glad that I was finally able to give you a little money by getting Pythonista 3. I would have happily paid ten times that amount.

                        zencuke i've been playing around with python a bit the last few months on mac. i've been programming for years. i'm new to pythonista. on the surface it would seem to me that it is basically just the same standard python but on an iOS device with perhaps some interfaces to some of the other apps / services on the device. not that this isn't cool. it is but because i'm new here and your enthusiasm is so high, i'm wondering if you might be more explicit and say specifically what is that is cool so i can personally see the light much quicker vs other contexts i'm currently using and cut to the chase to some functionality i'm probably easily overlooking? :)

                        btw, i don't see a pythonista app for the mac in Apps. so my guess is this is only an iOS thing right?

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

                          Pythonista is iOS only. The feature are described at http://omz-software.com/pythonista/ and http://omz-software.com/pythonista/docs/ios/ The modules like ui, scene, and canvas allow you to build iOS apps in Python. The inclusion of NumPy, Matplotlib, Requests, BeautifulSoup, Flask, Jinja2, Pillow, etc. are also quite powerful.

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