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.
pyui_embed.py yet another approach to .pyui files
-
Recent experiments with Pythonista ui building has proven to me the value of designing user interfaces with the pyui Editor. Creating UI elements in Python code that supports multiple screen sizes is far more verbose and error prone than I originally thought.
The trouble with .pyui files is that that are difficult to copy and paste when posting to and downloading from this forum and GitHub, etc. This has been eased somewhat in the new beta that allows you to change the file extension from .pyui to .json and back. This forum contains several other very interesting approaches to this problem.
I like pyui_embed.py because it creates a separate standalone .py file that allow you to mess around with the attributes of ui elements and see exactly how Pythonista will render them. It also puts a few lines of code onto the clipboard which you can paste into your main .py file so that the two .py files will work together to load the view without requiring the .pyui file.
If you are not running Pythonista v1.6 you will need to comment out the
dialogs
module calls and hard codefilename
to point to a .pyui file in the current working directory. -
@ccc, I have disagree. But maybe with a one level view, maybe easier. I did some tests trying to recreate the ui of contacts, notes, reminders in the ui builder. I think to do it nicely, you need many nested views. Then it becomes a mine field in code to deal with the pyui files. When creating the views in code you can split them into different custom classes and concentrate your coding on the particular class, then create a parent ui custom class to babysit the child views.
But I think is a good test is to try and recreate one of these screens (reminder, contacts, notes) in the ui and then try to code it orientation friendly.
Lol, I know I have gone out on a limb now :) pretty sure you will smack me with some great answer. But still only way to learn...challenge....challenge -
with proper use of the
flex
attributes, I think contacts, reminders, etc should be straightforward in the editor, at least on iPad. where it gets tricky Is when you want to actually hide things based on view. -
@JonB, hmmm, maybe I got a little carried away given my inexperience. I have got better since I last tried building up views with the ui Builder. I think it's a fantastic tool btw. I will have to try again.
-
Added
write_back_to_pyiu_file()
as an optional utility function that allows you to write all changes made to the UI element list back to the original .pyui file.