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.
Adding text to a TextView
-
I have a TextView in my UI called "task_textview" How do I set the text for it in my main script? I tried task_textview.text = "Foo", but I get "global name 'task_textview' is not defined". I didn't 'define' my buttons anywhere but in the UI editor and they work just fine.
-
You might need to address the text field relitive to the view that contains it...
class UserNameView(ui.View): def __init__(self): self.text_field = ui.TextField() self.text_field.text = 'ccc'
-
The view keeps a dictionary of it contained views by name. So you would do:
task_textview = myview['task_textview']
Then you can call the textview by the name
task_textview
. -
I just get "myview" is not defined.
I used the UI editor to create it, so I am calling it like this:
ui.load_view("menu").present("sheet")
I had to change that to:
my_view = ui.load-_view('menu')
my_view.present('sheet')
self.task_view = my_view['task_textview']
-
It's good practice to always assign things like a view to a variable, even if you're going to present it immediately. That way you can still call things like
my_view.close()
later. -
I just get "myview" is not defined.
Try "my_view" instead ;-)