Can anybody help me with a noob question:
I'm trying to learn using main function and class function. The code works fine until I add a function for a button. Now I get a NameError saying that the code inside is not defined
Here is a simple example for the code:
import ui
def Tapped(sender):
main_view.add_subview(L1)
def main():
main_view = ui.View(name = 'test')
main_view.background_color = 'white'
main_view.present()
L1 = ui.Label(text = 'test')
L1.frame = (50,50,50,50)
B1 = ui.Button(title = 'test')
B1.frame = (50,100,50,50)
main_view.add_subview(B1)
B1.action = Tapped
if __name__ == '__main__':
main()