Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 3
0
Arquivo: menu.py Projeto: isS/sy-game
 def __init__(self, options=[], align=HALIGN_CENTER, padding=4,
              on_select=None):
     self.align = align
     menu_options = self._make_options(options)
     self.options = dict(zip(options, menu_options))
     self.on_select = on_select
     self.selected = None
     VerticalLayout.__init__(self, menu_options,
                             align=align, padding=padding)
Exemplo n.º 4
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)
Exemplo n.º 5
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)
Exemplo n.º 6
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)
Exemplo n.º 7
0
 def _get_content(self):
     return Frame(
         VerticalLayout([
             SectionHeader(self.title),
             self.scrollable,
         ], align=HALIGN_LEFT)
     )
Exemplo n.º 8
0
    def __init__(self, path=os.getcwd(), extensions=[], title="Select File",
                 width=540, height=300, window=None, batch=None, group=None,
                 anchor=ANCHOR_CENTER, offset=(0, 0),
                 theme=None, movable=True, on_select=None, on_escape=None):
        self.path = path
        self.extensions = extensions
        self.title = title
        self.on_select = on_select
        self.selected_file = None
        self._set_files()

        def on_parent_menu_select(choice):
            self._select_file(self.parents_dict[choice])

        def on_menu_select(choice):
            self._select_file(self.files_dict[choice])

        self.dropdown = Dropdown(options=self.parents,
                                 selected=self.parents[-1],
                                 align=VALIGN_BOTTOM,
                                 on_select=on_parent_menu_select)
        self.menu = Menu(options=self.files, align=HALIGN_LEFT,
                         on_select=on_menu_select)
        self.scrollable = Scrollable(
            VerticalLayout([self.dropdown, self.menu], align=HALIGN_LEFT),
            width=width, height=height)

        content = self._get_content()
        Dialog.__init__(self, content, window=window, batch=batch, group=group,
                        anchor=anchor, offset=offset, theme=theme,
                        movable=movable, on_escape=on_escape)
Exemplo n.º 9
0
 def __init__(self,
              options=[],
              align=HALIGN_CENTER,
              padding=4,
              on_select=None,
              option_padding_x=0,
              option_padding_y=0):
     self.align = align
     self.option_padding_x = option_padding_x
     self.option_padding_y = option_padding_y
     menu_options = self._make_options(options)
     self.options = dict(zip(options, menu_options))
     self.on_select = on_select
     self.selected = None
     VerticalLayout.__init__(self,
                             menu_options,
                             align=align,
                             padding=padding)
Exemplo n.º 10
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)
     )
Exemplo n.º 11
0
    def __init__(self, text="", window=None, batch=None, group=None,
                 theme=None, on_escape=None):
        def on_ok(dialog=None):
            if on_escape is not None:
                on_escape(self)
            self.teardown()

        return Dialog.__init__(self, content=Frame(
            VerticalLayout([
                Label(text),
                Button("Ok", on_click=on_ok),
            ])),
            window=window, batch=batch, group=group,
            theme=theme, movable=True,
            on_enter=on_ok, on_escape=on_ok)
Exemplo n.º 12
0
Arquivo: menu.py Projeto: isS/sy-game
 def teardown(self):
     self.on_select = None
     VerticalLayout.teardown(self)
Exemplo n.º 13
0
 def teardown(self):
     self.folding_content.teardown()
     self.folding_content = None
     VerticalLayout.teardown(self)
Exemplo n.º 14
0
 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)]
Exemplo n.º 15
0
 def teardown(self):
     self.on_select = None
     VerticalLayout.teardown(self)
Exemplo n.º 16
0
 def teardown(self):
     self.folding_content.teardown()
     self.folding_content = None
     VerticalLayout.teardown(self)
Exemplo n.º 17
0
 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)]