Example #1
0
    def __init__(self, title, content=None, is_open=True, align=HALIGN_CENTER):
        Control.__init__(self)
        if align == HALIGN_LEFT:
            left_expand = False
            right_expand = True
        elif align == HALIGN_CENTER:
            left_expand = True
            right_expand = True
        else:  # HALIGN_RIGHT
            left_expand = True
            right_expand = False

        self.is_open = is_open
        self.folding_content = content
        self.book = Graphic(self._get_image_path())

        self.header = HorizontalLayout([
            Graphic(path=["section", "left"], is_expandable=left_expand),
            Frame(HorizontalLayout([
                self.book,
                Label(title, path=["section"]),
            ]),
                  path=["section", "center"],
                  use_bg_group=True),
            Graphic(path=["section", "right"], is_expandable=right_expand),
        ],
                                       align=VALIGN_BOTTOM,
                                       padding=0)
        layout = [self.header]
        if self.is_open:
            layout.append(content)

        VerticalLayout.__init__(self, content=layout, align=align)
Example #2
0
    def __init__(self, title, content=None, is_open=True, align=HALIGN_CENTER):
        Control.__init__(self)
        if align == HALIGN_LEFT:
            left_expand = False
            right_expand = True
        elif align == HALIGN_CENTER:
            left_expand = True
            right_expand = True
        else:  # HALIGN_RIGHT
            left_expand = True
            right_expand = False

        self.is_open = is_open
        self.folding_content = content
        self.book = Graphic(self._get_image_path())

        self.header = HorizontalLayout([
            Graphic(path=["section", "left"], is_expandable=left_expand),
            Frame(HorizontalLayout([
                      self.book,
                      Label(title, path=["section"]),
                  ]), path=["section", "center"],
                  use_bg_group=True),
            Graphic(path=["section", "right"], is_expandable=right_expand),
            ], align=VALIGN_BOTTOM, padding=0)
        layout = [self.header]
        if self.is_open:
            layout.append(content)

        VerticalLayout.__init__(self, content=layout, align=align)
Example #3
0
class FoldingSection(Control, VerticalLayout):
    def __init__(self, title, content=None, is_open=True, align=HALIGN_CENTER):
        Control.__init__(self)
        if align == HALIGN_LEFT:
            left_expand = False
            right_expand = True
        elif align == HALIGN_CENTER:
            left_expand = True
            right_expand = True
        else:  # HALIGN_RIGHT
            left_expand = True
            right_expand = False

        self.is_open = is_open
        self.folding_content = content
        self.book = Graphic(self._get_image_path())

        self.header = HorizontalLayout([
            Graphic(path=["section", "left"], is_expandable=left_expand),
            Frame(HorizontalLayout([
                      self.book,
                      Label(title, path=["section"]),
                  ]), path=["section", "center"],
                  use_bg_group=True),
            Graphic(path=["section", "right"], is_expandable=right_expand),
            ], align=VALIGN_BOTTOM, padding=0)
        layout = [self.header]
        if self.is_open:
            layout.append(content)

        VerticalLayout.__init__(self, content=layout, align=align)

    def _get_controls(self):
        return VerticalLayout._get_controls(self) + \
               [(self, self.header.x, self.header.x + self.header.width,
                       self.header.y + self.header.height, self.header.y)]

    def _get_image_path(self):
        if self.is_open:
            return ["section", "opened"]
        else:
            return ["section", "closed"]

    def hit_test(self, x, y):
        return self.header.hit_test(x, y)

    def on_mouse_press(self, x, y, button, modifiers):
        self.is_open = not self.is_open
        self.book.delete()
        self.book.path = self._get_image_path()
        if self.is_open:
            self.add(self.folding_content)
        else:
            self.remove(self.folding_content)
            self.folding_content.delete()

    def teardown(self):
        self.folding_content.teardown()
        self.folding_content = None
        VerticalLayout.teardown(self)
Example #4
0
    def __init__(self, text="", ok="Ok", cancel="Cancel",
                 window=None, batch=None, group=None, theme=None,
                 on_ok=None, on_cancel=None):
        def on_ok_click(dialog=None):
            if on_ok is not None:
                on_ok(self)
            self.teardown()

        def on_cancel_click(dialog=None):
            if on_cancel is not None:
                on_cancel(self)
            self.teardown()

        return Dialog.__init__(self, content=Frame(
            VerticalLayout([
                Label(text),
                HorizontalLayout([
                    Button(ok, on_click=on_ok_click),
                    None,
                    Button(cancel, on_click=on_cancel_click)
                ]),
            ])),
            window=window, batch=batch, group=group,
            theme=theme, movable=True,
            on_enter=on_ok_click, on_escape=on_cancel_click)
Example #5
0
    def __init__(self, title, align=HALIGN_CENTER):
        if align == HALIGN_LEFT:
            left_expand = False
            right_expand = True
        elif align == HALIGN_CENTER:
            left_expand = True
            right_expand = True
        else:  # HALIGN_RIGHT
            left_expand = True
            right_expand = False

        HorizontalLayout.__init__(self, content=[
                Graphic(path=["section", "left"], is_expandable=left_expand),
                Frame(Label(title, path=["section"]),
                      path=['section', 'center'],
                      use_bg_group=True),
                Graphic(path=["section", "right"], is_expandable=right_expand),
            ], align=VALIGN_BOTTOM, padding=0)
Example #6
0
 def _get_content(self):
     return Frame(
         VerticalLayout([
             SectionHeader(self.title),
             self.scrollable,
             Label("Directory:"),
             self.text_input,
             HorizontalLayout([
                 self.select_button, None, self.cancel_button
             ]),
         ], align=HALIGN_LEFT)
     )
Example #7
0
    def __init__(self, title, align=HALIGN_CENTER):
        if align == HALIGN_LEFT:
            left_expand = False
            right_expand = True
        elif align == HALIGN_CENTER:
            left_expand = True
            right_expand = True
        else:  # HALIGN_RIGHT
            left_expand = True
            right_expand = False

        HorizontalLayout.__init__(self,
                                  content=[
                                      Graphic(path=["section", "left"],
                                              is_expandable=left_expand),
                                      Frame(Label(title, path=["section"]),
                                            path=['section', 'center'],
                                            use_bg_group=True),
                                      Graphic(path=["section", "right"],
                                              is_expandable=right_expand),
                                  ],
                                  align=VALIGN_BOTTOM,
                                  padding=0)
Example #8
0
 def __init__(self, title, content):
     VerticalLayout.__init__(
         self,
         content=[
             HorizontalLayout([
                 Graphic(path=["titlebar", "left"], is_expandable=True),
                 Frame(Label(title, path=["titlebar"]),
                       path=["titlebar", "center"]),
                 Graphic(path=["titlebar", "right"], is_expandable=True),
             ],
                              align=VALIGN_BOTTOM,
                              padding=0),
             Frame(content, path=["titlebar", "frame"], is_expandable=True),
         ],
         padding=0)
Example #9
0
class FoldingSection(Control, VerticalLayout):
    def __init__(self, title, content=None, is_open=True, align=HALIGN_CENTER):
        Control.__init__(self)
        if align == HALIGN_LEFT:
            left_expand = False
            right_expand = True
        elif align == HALIGN_CENTER:
            left_expand = True
            right_expand = True
        else:  # HALIGN_RIGHT
            left_expand = True
            right_expand = False

        self.is_open = is_open
        self.folding_content = content
        self.book = Graphic(self._get_image_path())

        self.header = HorizontalLayout([
            Graphic(path=["section", "left"], is_expandable=left_expand),
            Frame(HorizontalLayout([
                self.book,
                Label(title, path=["section"]),
            ]),
                  path=["section", "center"],
                  use_bg_group=True),
            Graphic(path=["section", "right"], is_expandable=right_expand),
        ],
                                       align=VALIGN_BOTTOM,
                                       padding=0)
        layout = [self.header]
        if self.is_open:
            layout.append(content)

        VerticalLayout.__init__(self, content=layout, align=align)

    def _get_controls(self):
        return VerticalLayout._get_controls(self) + \
               [(self, self.header.x, self.header.x + self.header.width,
                       self.header.y + self.header.height, self.header.y)]

    def _get_image_path(self):
        if self.is_open:
            return ["section", "opened"]
        else:
            return ["section", "closed"]

    def hit_test(self, x, y):
        return self.header.hit_test(x, y)

    def on_mouse_press(self, x, y, button, modifiers):
        self.is_open = not self.is_open
        self.book.delete()
        self.book.path = self._get_image_path()
        if self.is_open:
            self.add(self.folding_content)
        else:
            self.remove(self.folding_content)
            self.folding_content.delete()

    def teardown(self):
        self.folding_content.teardown()
        self.folding_content = None
        VerticalLayout.teardown(self)