UI on desktop
ccc last edited by ccc
To force the use of Python 2, you can start your file (the VERY FIRST LINE!) with:
#!/usr/bin/env python# on non Pythonista platforms
-- or --
#!python2# on Pythonista
dgelessus last edited by
#!/usr/bin/env python2works on Pythonista, Windows, and any Unix that has a
python2in the PATH.
Ti Leyon last edited by
It is actually very easy to port Kivy scripts into Pythonista and vice versa. Pythonista's UI and Kivy's GUI are not exactly twins but they are definitely consanguineous in syntax. Adapting kivy codes to Pythonista's framework is nothing that the likes of @JonB, @ccc, @Phuket2, @dglesus and others in the Pythonista universe could not handle in their sleep. They know much more Python than I do and even more Pythonista specific idioms. About two years ago I wrote a few modules that adapt to both environments without any modifications to the source code. I usually work on a Mac book air with Virtualbox installed and running MS Windows, Ubuntu and Android. A shared folder between these environments is used to hold the Python scripts. Whenever I am satisfied with a project I can instantly test it on all the desktop platforms (OS X, ME Windows, Linux). Then I airdrop it to an iPad, paste it into a new Pythonista script and run it without modifying the source. Finally, I use "Send Anywhere" to bring it to an Android device and test it through the "Kivy Launcher" app. It matters because by unifying the outstanding works of @OMZ (Pythonista) and Mathieu Virbel (Kivy) you can easily and instantly test your work in all five major platforms at the source code level without any modification to your scripts. Maybe I should start a new thread about the subject and publish those modules.
ccc last edited by
It would be interesting to see a GitHub repo of these modules.
createpy last edited by
The complexity of porting Kivy scripts into Pythonista seems to be important to many in this post. Well, this problem seems to have casually been solved in the post bellow...
robopu last edited by
i'm tagging on to this thread just because i'm out here today. i confess i haven't used pythonista as much as i thought i would when i bought it a year ago but i have taken to simply installing python on my mac and doing a ton of scripting there. as a linux guy, i have never done any gui programming with any of the scripting languages i use for many administrative tasks. they're all command-line based.programs.
but i started thinking that some of the python code i'm writing would be easier to use / more reusable IF i could put a gui on top of it. i want to be able to assign python generated lists / arrays to a multi-select box which allows a user to select multiple items. these items then get assigned back to array so that python can process them.
when i searched online awhile ago, i didn't find much consensus on using a gui with python let alone for multi-select list boxes. the choices actually seemed pretty primitive (tkinter??).
so, i'm asking you python gurus what i might use with my mac python to superimpose a gui multi select on top of my script? if my python code can integrate with swift gui to turn it into an ios app so that i can run my code back in pythonista on my iphone with an interface that would be just as cool. or if something in xcode on the mac will allow me to put a gui on top of my python on the mac that's also just as cool. my thought is using some gui component for ios / swift and or mac might be more "slick" vs the primitive tkinters of the world etc.
thanks to all who might be able to provide a guiding hand
ccc last edited by ccc
Putting list into a multiple selection Pythonista ui is easy and requires no Swift...
import ui my_list = [x for x in 'abcdefghijklmnopqrstuvwxyz'] view = ui.TableView(name='My List') view.allows_multiple_selection = True view.data_source = ui.ListDataSource(my_list) view.present()
I recommend the
ui tutorialat https://github.com/Pythonista-Tools/Pythonista-Tools/blob/master/UI.md
On the desktop, check out Kivy and QT but be patient... They are easier than tkinter but not by much. https://docs.python.org/3.6/faq/gui.html
robopu last edited by
thanks ccc. i guess i need to set aside some time to really explore this. i've got other fish to fry now but all in due time.
Ti Leyon last edited by Ti Leyon
@robopu you may expand @ccc’s snippet into a structure called a “NavigationView” in Pythonista. You can probably adapt it to get the result you are expecting. An equivalent construct in Kivy is implemented in the “ScreenManager” module. You may even synchronize your code to run in both platform without modifications. Below are screenshots of a weak AI project I recently completed that used those structures.
plaquenil last edited by
Pythonista UI module is a part of Pythonista, which is an integrated development environment (IDE) for Python primarily designed for iOS devices like iPhones and iPads. It provides a user-friendly interface for creating iOS apps using Python.
However, Pythonista and its UI module are specific to iOS and are not available for desktop IDEs. If there have been any developments or third-party tools that enable you to use the Pythonista UI module on a desktop IDE, I would not have information on them. You may want to check the Pythonista website or other sources for the most up-to-date information on this topic.