What's with canvas in Pythonista 3.
I want to draw some simple mostly path based things so I decided to try canvas, For one reason or another I've never used it. I started with the first example (red circle) clicking on "open in editor" and running. Nothing visible happens. I know it is running because I can add print statements and they show. No errors. Just no graphics. I switch to Pythonista 2 and sure enough the example prints a big red circle as promised. It is agnostic. It fails on both 2,.7 and 3.5. I power cycled and tried again. Still nothing. Is this a known Pythonista 3 problem or is it just me?
@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.
@omz Works for me. ;-) The nice thing about Pythonista is that I have so many choices. Thanks for that.
turtle.py is (undocumented as far as i can tell) included in pythonista, at least as far back as 1.5
@JonB Not quite. I actually built a version of the
turtlemodule specifically for Pythonista 3, just a few months ago, and it is only available in Python 3 mode at the moment... The standard library
turtlemodule 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.
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)
I think you might find this will make your code work, at least it did for me:
Unless you are trying to see the individual dots appear one at a time...
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.
@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?
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.