Пример #1
0
    def _exit_confirmation(self):
        """
        Shows the exit confirmation box with common action buttons.
        """
        response = urwid.Text(['Do you really want to leave?'])

        def really_exit(_button):
            """ Actual exit. """
            return self._exit_program()

        apply = MenuButton('OK', really_exit)
        back_to_menu = MenuButton('Back', self.back)
        widget_list = [response, urwid.Divider(), apply, back_to_menu]
        box = urwid.Filler(urwid.Pile(widget_list))
        self.open_box(box)
Пример #2
0
    def __init__(self, title, text, frame, contents=None, actions=None):

        _header = urwid.Pile([('pack', urwid.Text(('title', title))),
                              ('pack', urwid.Divider())])

        if text:
            _header.contents.extend([(urwid.Text(text), _header.options()),
                                     (urwid.Divider('-'), _header.options())])

        self.body = []

        if contents:
            self.body.extend(contents)

        _body = urwid.ListBox(urwid.SimpleFocusListWalker(self.body))

        action_box = urwid.Pile([])

        if actions:
            action_box.contents.append(
                (urwid.Divider('-'), action_box.options()))
            action_box.contents.append(
                (MenuBtnGroup(self.actions), action_box.options()))

        _footer = action_box
        if _footer.contents:
            _footer.focus_position = 1  # the first one is Divider

        self.button = MenuButton(title, self.open, frame)
        self.frame = frame

        super().__init__(
            urwid.Pile([('pack', _header), _body, ('pack', _footer)]))
Пример #3
0
    def load_user(self, user, button_list):
        profile_name = user.profile.name
        file_name = 'avatar_' + string_to_image_name(profile_name)
        avatar = resource_find(file_name)
        self.drawer_header.header_profile.text = profile_name
        print('user= '******'user last= ', user.name_last)
        full_name = user.name + ' ' + user.name_last
        self.drawer_header.header_name.text = full_name
        self.drawer_header.header_email.text = user.e_mail
        self.drawer_header.header_image.source = avatar

        for button in button_list:
            menu_button = MenuButton()
            menu_button.screen_name = button
            menu_button.text = self.app.ui_text_lib[button]
            self.ids._main_menu_buttons.add_widget(menu_button)
Пример #4
0
 def output_script(self, text):
     """
     Shows the output of script.
     """
     back_to_menu = MenuButton('Back', self.back)
     scrolling = urwid.Pile([urwid.Text(text)])
     output = urwid.ListBox(urwid.SimpleListWalker([scrolling]))
     box = urwid.Pile([output, ('pack', back_to_menu)])
     self.open_box(box)
Пример #5
0
    def __init__(self,
                 title,
                 text,
                 frame,
                 top_level=False,
                 contents=None,
                 checkbox_group=False,
                 script=''):

        self.actions = []
        self.parameters = []
        self.count_click_select_all = 0
        self.checkbox_group = checkbox_group
        self.elements = contents[:]

        if self.checkbox_group:
            for item in self.elements:
                urwid.connect_signal(item, 'postchange', self.checkbox_changed)

            self.actions.append(MenuButton('Select all', self.select_all))

        if not top_level:
            self.actions.append(MenuButton('Back', frame.back))

        if script:
            self.actions.append(
                ScriptButton('Apply...',
                             script=script,
                             parameters=self.parameters,
                             output=frame,
                             confirmation=True))
        body = contents[:]

        super().__init__(title, text, frame, body, self.actions)

        self.button.change_label(self.button.label + "...")
Пример #6
0
    def __init__(self, title, text, frame, contents=None, script=''):
        self.actions = []
        self.parameters = []

        self.actions.append(MenuButton('Back', frame.back))
        if script:
            self.actions.append(
                ScriptButton('Apply...',
                             script=script,
                             parameters=self.parameters,
                             output=frame,
                             confirmation=True))

        body = []
        if contents:
            body.extend(contents)

        super().__init__(title, text, frame, body, self.actions)
Пример #7
0
 def add_button(self):
     show_button = MenuButton(self.dialogue_box_list[0],
                              60,
                              self.height - 30,
                              theme=self.theme)
     self.button_list.append(show_button)