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 change label.text
-
Hello everybody
Labels have text attribute so I suppose it’s possible to change that but Labels don’t have action line in the GUI, no function to link with.
Is there a way to access Labels and other windows in the view via ui ? -
Here you can find the manual for the ui module and a tutorial.
-
@philippe as usual, not sure I correctly understand your request.
Try this code. It uses the name attribute of the label to be accessed in the button actionimport ui v = ui.View() v.frame = (0,0,400,400) v.background_color = 'lightgray' l = ui.Label(name='label') l.frame = (10,10,380,32) l.background_color = 'white' l.text = 'initial' v.add_subview(l) b = ui.Button() b.frame = (10,50,380,32) b.background_color ='white' b.title ='change label text' def b_action(sender): b.superview['label'].text = 'new text' # b.superview is v, v['label'] refers thus to your label b.action = b_action v.add_subview(b) v.present('sheet')