Пример #1
0
    def _config(self, **kwargs):
        """
          widgets: ``list`` Contains widgets to pack into box.
              The order of widgets in the list denotes order they are packed.
          border: ``int`` Number of pixels to space around edges when ``surf``
              is not given.
          col: ``tuple`` (r,g,b) Colour for background, 0 is transparent.
          spacing: ``int`` Number of pixels to space between widgets.

        """
        if "spacing" in kwargs:
            self._settings["spacing"] = kwargs["spacing"]
        if "widgets" in kwargs:
            pos = 0
            # Shift widget positions so all labels are displayed.
            height = 0
            for w in kwargs["widgets"]:
                if w._label is not None and w._label.side == "top":
                    height = max(height, w._label.rect.h)

            for w in kwargs["widgets"]:
                offset = 0
                if w._label is not None:
                    if w._label.side == "left":
                        offset = w._label.rect.w
                    r = w.rect.union(w._label.rect)
                else:
                    r = w.rect
                w.pos = (pos + offset, height)
                pos += r.w + self._settings["spacing"]
        Container._config(self, **kwargs)
Пример #2
0
    def _config(self, **kwargs):
        """
          widgets: ``list`` Contains widgets to pack into box.
              The order of widgets in the list denotes order they are packed.
          border: ``int`` Number of pixels to space around edges when ``surf``
              is not given.
          col: ``tuple`` (r,g,b) Colour for background, 0 is transparent.
          spacing: ``int`` Number of pixels to space between widgets.

        """
        if "spacing" in kwargs:
            self._settings["spacing"] = kwargs["spacing"]
        if "widgets" in kwargs:
            pos = 0
            # Shift widget positions so all labels are displayed.
            height = 0
            for w in kwargs["widgets"]:
                if w._label is not None and w._label.side == "top":
                    height = max(height, w._label.rect.h)

            for w in kwargs["widgets"]:
                offset = 0
                if w._label is not None:
                    if w._label.side == "left":
                        offset = w._label.rect.w
                    r = w.rect.union(w._label.rect)
                else:
                    r = w.rect
                w.pos = (pos + offset, height)
                pos += r.w + self._settings["spacing"]
        Container._config(self, **kwargs)