Automatic .py-script from .pyui?
Hello coder community,
I am new to Python and I haven't written code for some while.
I specifically want to write gui with python.
At home I have managed to install Pyqt5 and run some test variants in Visual Studio Code.
My biggest problem was that all video tutorials are dated.
They refere to Python 2.7 or some Python 3 variants before Python 3.5.
Nevertheless now I know how and what to import.
On the go I want to learn and use python as well.
That is why I want to ask:
Is there a way that placed modules in the .pyui file are implemented
in the .py file as code automatically?
That would drastically help me.
Right now I don't even know what to write to talk to the .pyui file, nor to the
modules in it. Like to a button.
Thank you in advance.
I found und this topic:
The given code doesn't work, because there is no module "workflow"
that I can import.
Do I have to install this module "workflow" first?
dgelessus last edited by
workflowmodule only exists in Editorial, which is another app from the developer of Pythonista (it's a text editor for languages like Markdown, and allows automation via "workflows" and Python scripts). The code from the thread you linked only makes sense within an Editorial workflow, it does some work with a view loaded from the workflow. In Pythonista you can do basically the same using
That doesn't do what you're looking for though - while
ui.load_viewmakes the contents of a .pyui file available as a
ui.Viewobject in the Python script, there's no built-in way to convert that back to Python code. It's possible that someone has written a script to convert a .pyui to Python code, but if so I don't remember. Maybe someone else knows.
ccc last edited by
https://github.com/humberry/ui-tutorial Is a good place to start.
Treenjood last edited by Treenjood
I want to thank you both for helping me.
It would be helpful if Pythonista would allow to copy an existing script / file and be able to rename this file.
Than I could rename the .pyui file to an .py file and just read what Pythonista does in the background.
Nevertheless I will look up the examples / tutorials on GitHub.
The .pyui scripts are exactly what I wanted to see.
Right now I can´t do anything with them, but it´s good to know how I could look them up.
Thank you :)
OK. Got it.
I have to import the hello_world_v2.pyui script first and copy it into a script file. Can be hello_world_v2.py as well and then change .py to .pyui. When I have imported the .py text into the hello_world_v2.py file I have to rename the .pyui file to hello_world_v2_1.py to read the script.
Great. That´s how I can learn.
ccc last edited by ccc
.pyuifiles are not Python files. Instead,
.pyuifiles contain json. The Python interpreter can not execute a
.pyuifile but Pythonista's ui module can load them and render their ui.
Normally when you open a
.pyuifile in the Pythonista editor, it opens them in the ui builder so that you can view and modify the ui elements. If you want to view the json code in a
.pyuifile then you need to change the file extension of that file
.json. You do this by clicking on the title of the file in the editor and then clicking the box with three dots [...] just to the right of the title. MyFile.pyui will open in the ui builder and MyFile.json will be viewable/editable as json text.
coomlata1 last edited by coomlata1