Develop/test in Pythonista, also run on Raspberry Pi?
Hi all. I’d like to use Python to write a simple full-screen app, which involves receiving mouse events, and doing basic custom drawing into a view. This would be easily done using the ui package in Pythonista for deployment on my iPad, but the ultimate destination is a Raspberry Pi device.
If I wanted to develop solely on the Pi, I’d probably use tkinter, or pygame, or another such framework — but I’d love to do the actual dev and testing on my iPad first, via Pythonista, then just deploy to the Pi when the app is ready.
Thus, my question: is there any common Python UI framework between Pythonista and a Raspberry Pi (I can of course install anything on the Pi that’s needed) which will allow me to use Pythonista to write and test such a full-screen, custom-drawing, mouse-events-receiving app, but which I can also then deploy on a Raspberry Pi with little to no changes?
Apologies for the niche question. Thank you.
cvp last edited by
is there any common Python UI framework between Pythonista and a Raspberry PI
JonB last edited by
JonB last edited by
That said, if you truly are doing just basic drawing, and not using buttons, tables, or any of the native views of iOS or objc, it probably wouldn't be TOO hard to create wrappers that perform the basic functionality depending on platform. You'd have to wrap the basic rectangle, line, ellipse, and arc drawing functions, and features for setting drawing style (stroke color, width, etc). Functionally you can probably mimic everything that a pythonista draw() function does (or in general, drawing to an ui.ImageContext) using a tkinter.Canvas or the like. It might be harder going the other way.
You might find
useful. Zac created a generic Canvas class with backends in multiple frameworks (pillow, pythonista, CoreGraphics and a few others). You might be able to add a backend for whatever your preferred framework on pi is, or just do everything in Pillow and update the image (might be slower).
@JonB Thanks so much for that. Creating thin shims for each platform was certainly my second-place option, and might be an interesting project to open source! I’ll take a look at geometriq too.
I did consider going the HTML route, but as you say it would probably be best in that case to take python out of the equation in the first place. I’ll explore some options.
Thanks again for your time and reply (and to @cvp)!