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.
Trying to create a simple script with UI Designer
-
Greetings,
I'm brand new to Pythonista and I want to use UI Designer to create a form.
Within UI Designer, I have added a LABEL box to the file 'My UI.pyui', and have changed the LABEL box's 'Name' attribute to 'Connect_label'.
All I want to do is to change the LABEL box's TEXT attribute to "Fred", but I get an error:
"name 'Connect_label' is not defined'I would have thought that by loading the "My UI" form (and that works) that I could have access to and modify the LABEL box's attributes. Do I need to add something else in the code?
Here's the code:
import ui
ui.load_view('My UI').present('sheet')Connect_button.text = 'Fred'
-
You can access a views ui elements using the subscript syntax:
view = ui.load_view() view["connect_label"].text = "text" view.present("sheet")
-
LK,
That causes even more errors.
If, just after:
ui.load_view('My UI').present('sheet')
I add:
view = ui.load_view()I get this error:
[Errno 2] No such file or directory...Bob
-
- you have to replace the ui.load_view().present() line with my code
- your
pyui
file needs to have the same file name as the script you're callingload_view
in
-
Lukas,
I got it. That works! Thanks.
May you live to be one-thousand years old, sir.
Bob