ui.view.close() not working as expected
-
I’m sorry if this has an obvious answer, but I am unable to get this to work. I want to use a custom close button but it doesn’t work for me. What am I missing? Thank you!
` import ui
v = ui.View()
b1 = ui.Button(title = "why doesn't this close button work?")
b1.frame = (50,100,270,50)
b1.background_color = '#d0d0d0'
b1.action = v.close()v.add_subview(b1)
v.present('fullscreen', hide_title_bar=True)```
-
try v.close, not v.close()
the first way is a function handle.
the second way calls the function (which returns None).
-
sorry, actions must accept one argument, sender. here are two options
'''action must take one argument -- sender which will be the button. a lambda will wrap this....''' b1.action = lambda sender: v.close() ''' alternatively, allow for other cleanup if needed''' def close_parent(sender): sender.superview.close() b1.action = close_parent
-
Thank you JonB! I knew I must be missing something, and I never would have figured that out.