UI on desktop
Is it possible to get the Pythonista UI module on a desktop ide?
Yes - it looks like Kivy was off the plate back then due to license issues and there is some heated discussion about it as you read along. It was all about Kivy using LGPL 3, but they switched to an MIT license since then and at least one App is being sold for $75 on IOS that does some pretty fancy process diagramming. Still - the IOS support is not as evolved as the Android support. Lots more Android apps out there using it then IOS. Sure looks like the place to go to get PyGame support done if that ever becomes a goal.
Solution (for mac):
- Download and install Xcode
- Download PythonistaProjectTemplate.zip
- Paste in your script
- Run in a simulator
I know it's kind of awkward, but you can get your pythonista code run on mac!
@ShadowSlayer: I tried pcista to port a simple game I wrote on my phone, but ran into a problem:
translateseems not to be supported, and I use it. Also, pcista looks like it's Python 2 only (
string.uppercaseno longer exists in Python 3). Cool idea though, I'd like to be able to use pcista.
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
#!/usr/bin/env python2works on Pythonista, Windows, and any Unix that has a
python2in the PATH.
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.
It would be interesting to see a GitHub repo of these modules.
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...
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
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
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.
@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.