• Checkmate

    Can I change the value of a variable in a function called by a button?

    I tried it like this but it does not work sadly

    “ UnboundLocalError: local variable 'x' referenced before assignment”

    import ui 
    
    x = 100
    
    def action1(sender):
        x -= 1
    
    
    view = ui.load_view()
    button = view["button1"]
    button.action = action1
    view.present('sheet')
    

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!