I want to import certain files based on input from the user using some sort of selection (I am using a radio button). I am having trouble getting the updated selection from the user to send to check the input and go to the desired page for the selection while importing the desired classes from another Python file in the process.
For example, suppose from another file scriptA.py
, I have the class:
class A:
def __init__(self, a):
self.a = a
and from scriptB.py
I have the class
class B:
def __init__(self, b):
self.b = b
In my app script app.py
, I want to obtain the input for the user and given the input, go to the desired page and importing the class for the input:
class ImportSelection:
def __init__(self, selection = None):
self.selection = selection
importselection = ImportSelection()
ui.radio(['A', 'B']).bind_value(importselection, 'selection')
@ui.page('/A')
def page_A():
from scriptA import A
# do stuff
@ui.page('/B'):
def page_B():
from scriptB import B
# do stuff
if importselection.selection == 'A':
ui.link("/A", page_A)
elif importselection.selection == 'B':
ui.link("/B", page_B)
ui.run()
I am having trouble getting the user input to then go to the page. How should I refactor this code to do this? Thank you in advance!