Hi,
I’m struggling to find a way to re-factor the following code to have a single method which accepts arguments when called from a Scene UI button, rather than two very similar ones. Any suggestions very welcome! Thanks.
def show_view_A(sender):
v = ui.View()
v.background_color = ‘white’
v.name = ‘A’
global location
location = 1 # used in another method to grab a url
sender.navigation_view.push_view(v)
message = get_html(page_info,location_info)
scrollview(v,message)
def show_view_B(sender):
v = ui.View()
v.background_color = ‘white’
v.name = ‘B’
global location
location = 2 # used in another method to grab a url
sender.navigation_view.push_view(v)
message = get_html(page_info,location_info)
scrollview(v,message)
root_view = ui.View()
root_view.background_color = 'white'
root_view.name = 'Stuff'
A = ui.Button(title='A')
B = ui.Button(title='B')
A.action = show_view_A
B.action = show_view_B
root_view.add_subview(A)
root_view.add_subview(B)