I have many, many forms I need to switch between in my content_panel (material design template). I have taken to creating a “routing” module but find I am creating tons of functions for each form load.
What I mean is this :
def show_dashboard():
from Dashboard import Dashboard as new_form
get_open_form().content_panel.clear()
get_open_form().content_panel.add_component(new_form())
and I call it from my forms thusly :
routing.show_dashboard()
It makes the forms much tidier but it comes at a cost, which is every time I must cut/paste the above function, changing the names. I think I’m up to about 50 odd now, and the routing module is somewhat unwieldy.
What I want to do is create a function like this :
routing.show_form("Dashboard")
where the function can take the parameter and dynamically import the form and load it into the content panel. Problem is, I can’t use __import__
and nor can I use importlib
(neither, I assume, being supported by Skulpt’s version 2-ish of Python).
Is there any way in which I can achieve what I want? Or has anyone got a better suggestion?