Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
UI on desktop
-
Is it possible to get the Pythonista UI module on a desktop ide?
-
One would have to write a wrapper around the ui functions and classes, and implement them in Tkinter or another ui framework. It will be nontrivial, and unlikely to exactly match what pythonista is doing, as there is a lot of native behavior going in under the hood.
Someone tried this for the
scene
module. https://github.com/Vik2015/pythonista-pc It was a good start, but you can see how much was left to do.scene
is much much simpler thanui
-
Ok.
-
The Vik2015 project has been relocated as pcista. It is trying to map Scene over to PyGame which is based on SDL and is cross platform. Before ui was part of Pythonista there seemed to be lots of people including Vik2015 trying to create ui like widget sets based on Scene so you will run into lots of abandoned code that has this kind of thing. The author of Pythonista obviously decided that it was better to create a true Python based access layer to the native IOS widgets rather then port Tkinter or Qt or something else. The whole thing makes me wonder now whether the approach taken by Kivy (www.kivy.org) is really the way to go. It also makes me wonder how difficult it would be to merge or host Kivy in Pythonista. Kivy has no IDE of its own but it is working on a shell of some kind.
-
@wradcliffe, I don't know how exactly Kivy works (never really used it), but I guess it is possible to write a layer on top of
scene
with Kivy-like functions n stuff. It probably won't be able to support all it's features but would be enough to run some basic programs.P. S. I am the Vik2015 from GitHub :). I kinda abandoned pcista because I didn't really see anyone being interested in it. Thought now it seems like there are more and more people asking for such kind of stuff, so I may try to finish the port.
-
omz on 12 Nov 2012 wrote
: [Kivy] certainly looks interesting, the LGPL license could be problematic though. -
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:
translate
seems not to be supported, and I use it. Also, pcista looks like it's Python 2 only (string.uppercase
no 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 python2
works on Pythonista, Windows, and any Unix that has apython2
in 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...
https://forum.omz-software.com/topic/3964/unipage-as-a-bridge-between-kivy-and-pythonista -
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 tutorial
at https://github.com/Pythonista-Tools/Pythonista-Tools/blob/master/UI.mdOn 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.