Beispiel #1
0
 def __init__(self, options):
     # parse string shorthand
     if isinstance(options.get("icon", None), str):
         self.image = resolve_image_option(options["icon"],
                                           default_height="64px")
     else:
         # apply user config dict
         for key, value in options.get("icon", {}).items():
             setattr(self, key, value)
         if not hasattr(self, "height"):
             self.height = "64px"
         if hasattr(self, "image"):
             self.image = resolve_image_option(self.image,
                                               default_height=self.height)
         if hasattr(self, "onpress"):
             self.onpress = resolve_onpress_option(self.onpress)
Beispiel #2
0
    def __init__(self, options):
        # apply user config dict
        for key, value in options.get("actionbar", {}).items():
            setattr(self, key, value)

        if hasattr(self, "actions"):
            for action in self.actions:
                action["icon"] = resolve_image_option(action["icon"],
                                                      default_height="24px")
                if action.get("onpress", None):
                    action["onpress"] = resolve_onpress_option(
                        action["onpress"])
Beispiel #3
0
    def __init__(self, options):
        """
        This section contains an image at the top of the card.

        :param options: (dict) the key/value pairs from this section of the
        card's config toml
        """

        # parse string shorthand
        if isinstance(options.get("icon", None), str):
            self.image = resolve_image_option(options["icon"], default_height="64px")
        else:
            # apply user config dict
            for key, value in options.get("icon", {}).items():
                setattr(self, key, value)
            if not hasattr(self, "height"):
                self.height = "64px"
            if hasattr(self, "image"):
                self.image = resolve_image_option(
                    self.image, default_height=self.height
                )
            if hasattr(self, "onpress"):
                self.onpress = resolve_onpress_option(self.onpress)
Beispiel #4
0
    def __init__(self, options):
        self.items = []
        # apply user config dict
        for key, value in options.get("list", {}).items():
            setattr(self, key, value)

        if not hasattr(self, "alignment"):
            self.alignment = "left"

        for item in self.items:
            if item.get("icon"):
                item["icon"] = resolve_image_option(item["icon"], default_height="24px")
            if item.get("onpress"):
                item["onpress"] = resolve_onpress_option(item["onpress"])
Beispiel #5
0
    def __init__(self, options):
        """
        The bar at the bottom of the card with configurable buttons.

        :param options: (dict) the key/value pairs from this section of the
        card's config toml
        """

        # apply user config dict
        for key, value in options.get("actionbar", {}).items():
            setattr(self, key, value)

        if hasattr(self, "actions"):
            for action in self.actions:
                action["icon"] = resolve_image_option(action["icon"],
                                                      default_height="24px")
                if action.get("onpress", None):
                    action["onpress"] = resolve_onpress_option(
                        action["onpress"])
Beispiel #6
0
    def __init__(self, options):
        """
        This section is an area below the description (if present). In this section
        you can create a list of items with an icon, a title, and onpress action

        :param options: (dict) the key/value pairs from this section of the
        card's config toml
        """

        self.items = []
        # apply user config dict
        for key, value in options.get("list", {}).items():
            setattr(self, key, value)

        if not hasattr(self, "alignment"):
            self.alignment = "left"

        for item in self.items:
            if item.get("icon"):
                item["icon"] = resolve_image_option(item["icon"],
                                                    default_height="24px")
            if item.get("onpress"):
                item["onpress"] = resolve_onpress_option(item["onpress"])