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.
having to do with classes and instants and scope - I don't know what to call it
-
I have added a label (label1) in the Ui designer. Is there something I can preface my reference to it in the offending line so that it can be found?
What is the name of the main view when it is created by the Ui designer?import ui
def button_tapped(sender):
sender.title = 'Hello' label1.text = 'hello' <-------------------------- causes error
ui.load_view('My UI').present('sheet')
-
ui.load_view
returns aui.View
instance which corresponds to the root view of the .pyui file. A view's subviews can be accessed like the items of a dict (e. g.root["label1"]
).import ui root = ui.load_view() # With no parameters it will load the view named like your script root["label1"].text = "I am a happy label." root.present("sheet")
-
Thanks. That did just what I needed.