tkinter on pythonista
gpjma last edited by
Can I use tkinter with the pythonista app on iOS?
If so how do I load?
I did use import tkinter on my 10 inch Ipad pro and I got no error.
On my 12 inch iPad Pro with the same script i get an error no such module?
Any Help fo a new person on Pythonista?
Clint last edited by
I’m having same problem...so far I just copy/pasted the tkinter.py text file and saved it as a new python file, this solved the error of “Tkinter module not found” but now it’s saying “cannot import name ‘_flatten’ , which is on the second line of code of Tkinter, stuck there right now. Lmk if you get any further as well.
Phuket2 last edited by
Guys, tkinter can't be used in Pythonistia. Tkinter is for desktop ui's not mobile. Pythonistia comes with a ui module. You use this to make a GUI in Pythonistia. Its very good. There also is a ui designer. If you select 'UIFile' when creating a new file, once its created you will see you are in the UI Designer. You can also do in code, have a look at the UI module in the docs
ellie_ff1493 last edited by
It’s not possible to use tkinter on iOS. even if you somehow get it working, its not going to be useful because it’s made for keyboard and mouse
gpjma last edited by
Thanks very much for your insight. It is a pity a as i need to develop a windowed app and have gotten attached to Tkinter.
I thought that Pythonista would allow me to develop the app whilst away from my desk or laptop.
I will have a look at the UI tools and see where it leads.
crazyblob last edited by
What if we wanted to develop programs that pretty much any desktop user can run.. will we only be able to develop console and pythonista stuff?
mapmangame last edited by
You could try writing a web app in Flask within pythonista. I believe there are a few tools that let you turn flask apps into standalone desktop apps (although I haven't tried them myself) e.g. https://github.com/Widdershin/flask-desktop
Maybe someone on the forum has experience of this strategy? I would be interested to try it myself sometime.
AtomBombed last edited by
Yeah, Tkinter is not Pythonista-compatible. I'm pretty sure this has something to do with it not being entirely Python. It's an interface to the Tk framework that lower-level languages like C++ use. It's a machine code library, and thus couldn't run in Pythonista due to the extent that Apple goes to prevent apps from running executables.
But let's say you could get Tkinter to run on Pythonista. It wouldn't work because Pythonista doesn't have anything that handles the rendering of the windows and widgets that Tkinter produces.
Of course, you could write something to work around this. Maybe you could embark on a project to make a Flask application that presents your Tkinter GUI as a webpage that Flask serves locally. Then you could have it open that local page with
webbrowser.open("http://localhost:8080")or something similar.
Or you could write something to display Tkinter applications as native Pythonista UIs.
This may be out of your scope (I know I would have trouble with this). I'm not sure if anyone else has attempted this before. Sorry!
JonB last edited by
There have been a few attempts at "universal" UI frameworks that let you simulate a small subset of features on desktop and pythonista. search forums for unipage, which is Kivy based. There was also an attempt by someone to create a dummy pythonista UI module that interfaced to tkintker or some other framework.
In both cases you end up with a very limited Subset if the full feature set, since it is difficult if not impossible to capture all of the subtleties of native code, and differences in interface. I think someone also has posted examples of a web based (flask/js) approach that would be near universal, but doesn't really lend itself to easy development in the iPad.
What might be better is to try to write your code such that the backend logic is standalone, not relying on any UI. Then write your user interface code such that it checks platform, and presents using the appropriate native library. Easier said than done.