import gui

class Mgr_Screens:
    obj_count = 0

    # TODO move away from dict
    # maybe not ???
    Screens = {"Empty":[gui.DL_NOP()]}
    Current_Screen = "Empty"


    def __init__(self):
        if Mgr_Screens.obj_count != 0:
            raise RuntimeError('Mgr Screens: there can be only one')
        Mgr_Screens.obj_count += 1

    @classmethod
    def Add_Screen(cls,screen, key, start = False):
        cls.Screens[key] = screen
        if start:
            cls.Current_Screen = cls.Screens[key]
            cls.Current_Screen.setup()
            gui.show(cls.Current_Screen.gui_l)

    @classmethod
    def Set_Screen(cls,key):
        cls.Current_Screen.teardown()
        cls.Current_Screen = cls.Screens[key]
        cls.Current_Screen.setup()
        gui.show(cls.Current_Screen.gui_l)
