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.
How to reference textfield
-
I'm just starting to play with the ui module. I created a simple test program and ui with a textfield on it using the ui tool. I can't figure out how to get a reference to the text field so can access it from the code.
-
The easiest way is to reference it by name, using the dict-like notation. When you load a view like this...
v = ui.load_view()
...and your UI file contains a text field with the name
textfield1
, you can get a reference to it like this:# ... textfield = v['textfield1']
-
You can access the different views with a dictionary like syntax, and you access them with their names. If you load the main view to a variable (let's call it <I>root_view</I>), you can access the textfield view like this:
root_view['textfield1']
(<I>textfield1</I> is the default name)<br>
The textfield view has an additional variable named text, which of course stores the text data, and is accessed like this:root_view['textfield1'].text
I don't know if this is what you meant, but.. Oh well, I tried XD
Edit:
I was to late XD -
Sorry for not responding, thought I'd receive an email when there was a response. I finally figured out both methods, but thanks for the reply!