예제 #1
0
    def add_screen(self, screen_name):

        # Get the info we need to import this screen
        foundscreen = [p for p in getPlugins() if p["name"] == screen_name]

        # Check we've found a screen and it's not already running
        if foundscreen and screen_name not in self.available_screens:

            # Get the details for the screen
            p = foundscreen[0]

            # Import it
            plugin = imp.load_module("screen", *p["info"])

            # Get the reference to the screen class
            screen = getattr(plugin, p["screen"])

            # Add the KV file to the builder
            Builder.load_file(p["kvpath"])

            # Add the screen
            self.scrmgr.add_widget(
                screen(name=p["name"], master=self, params=p["params"]))

            # Add to our list of available screens
            self.available_screens.append(screen_name)

            # Activate screen
            self.switch_to(screen_name)

        elif screen_name in self.available_screens:

            # This shouldn't happen but we need this to prevent duplicates
            self.reload_screen(screen_name)
예제 #2
0
    def remove_screen(self, screen_name):

        # Get the list of screens
        foundscreen = [
            p for p in getPlugins(inactive=True) if p["name"] == screen_name
        ]

        # Loop over list of available screens
        while screen_name in self.available_screens:

            # Remove screen from list of available screens
            self.available_screens.remove(screen_name)

            # Change the display to the next screen
            self.next_screen()

            # Find the screen in the screen manager
            c = self.scrmgr.get_screen(screen_name)

            # Call its "unload" method:
            if hasattr(c, "unload"):
                c.unload()

            # Delete the screen
            self.scrmgr.remove_widget(c)
            del c

        try:
            # Remove the KV file from our builder
            Builder.unload_file(foundscreen[0]["kvpath"])
        except IndexError:
            pass
예제 #3
0
 def process_plugins(self):
     # Build a dictionary of screens, their current state and whether or not
     # they provide a custom screen
     self.screens = {
         s["name"]: {
             "web": s["web"],
             "enabled": s["enabled"]
         }
         for s in getPlugins(True)
     }
예제 #4
0
# Set the current working directory
os.chdir(os.path.dirname(os.path.abspath(sys.argv[0])))

VERSION = "0.3.1"


class InfoScreenApp(App):
    def build(self):
        # Window size is hardcoded for resolution of official Raspberry Pi
        # display. Can be altered but plugins may not display correctly.
        Window.size = (800, 480)
        return InfoScreen(plugins=plugins)

if __name__ == "__main__":
    # Get a list of installed plugins
    plugins = getPlugins()

    # Get the base KV language file for the Info Screen app.
    kv_text = "".join(open("base.kv").readlines()) + "\n"

    # Loop over the plugins
    for p in plugins:

        # and add their custom KV files to create one master KV file
        kv_text += "".join(p["kv"])

    # Load the master KV file
    Builder.load_string(kv_text)

    # Good to go. Let's start the app.
    InfoScreenApp().run()
예제 #5
0
    def build(self):
        # Window size is hardcoded for resolution of official Raspberry Pi
        # display. Can be altered but plugins may not display correctly.
        Window.size = (800, 480)
        self.base = InfoScreen(plugins=plugins)
        return self.base


if __name__ == "__main__":
    # Load our config
    with open("config.json", "r") as cfg_file:
        config = json.load(cfg_file)

    # Get a list of installed plugins
    plugins = getPlugins()

    # Get the base KV language file for the Info Screen app.
    kv_text = "".join(open("base.kv").readlines()) + "\n"

    # Load the master KV file
    # Builder.load_string(kv_text)
    Builder.load_file("base.kv")

    # Loop over the plugins
    for p in plugins:

        # and add their custom KV files to create one master KV file
        # kv_text += "".join(p["kv"])
        Builder.load_file(p["kvpath"])