Forum Archive

Tkinter to Pythonista UI

ihf

I realize that Pythonista does not (cannot) support Tkinter but I wondered (perhaps naively) whether it was possible to write a Pythonista script which mapped a Tkinter dependent Python script to the Pythonista UI? Is that a crazy idea? If not, has anyone given any thought to doing it?

dgelessus

Possibly the biggest problem with porting Tkinter is that, as I understand it, it is a wrapper for the Tcl language used by the Tk toolkit. Reimplementing Tkinter would probably involve reimplementing parts of the Tcl language, and writing a language lexer/parser/interpreter is an even more daunting task than "just" porting an extensive GUI toolkit in a useful way.

Just for fun I tried implementing the easygui library using console and ui, which worked out surprisingly well for the most part. As the name implies it is far more simple than most other toolkits, in terms of complexity it is similar to the dialogs module from Beta 1.6. If anyone is interested I might fix some of the current problems and put it on GitHub.

turtle might also be an interesting project to port, while it is obviously not a GUI toolkit and isn't used in any major applications, it would definitely be helpful for Python (and programming in general) newcomers.

ccc

See OMZ's start on the turtle idea... https://gist.github.com/4413863

zencuke

I believe that the python tkinter uses the standalone Tk library. Tk has long since been extracted from Tcl since it has been ported to so many languages. On the other hand translating from one ui toolkit to another is usually very difficult. They tend to have detailed but incompatible low level assumptions, particularly about event handling, that don't translate well without a lot of custom low level (i.e. C code) glue. Basically you would have to first port the portable Tk library to iOS then write a C wrapper for it in Pythonista. I don't think the ui module has enough functionality to support tkinter. tkinter has a pretty extensive functionality set.