コード例 #1
0
ファイル: manager.py プロジェクト: kuralabs/coral-dashboard
    def create_pop_up(self):
        line_box = LineBox(
            Filler(Text(self._text, align='center')),
            title=self._title,
        )

        return AttrMap(line_box, 'popup')
コード例 #2
0
    def __init__(self, list_data=None):

        self.is_editing = False
        self.tasks = []
        self.name = None
        self.group = None
        self.id = None

        if list_data:
            # Parse the data.
            self.parse_data(list_data)
        else:
            # Must be a new list
            self.name = 'untitled'
            self.group = 'none'
            self.id = uuid.uuid4().hex

        # AttrSpecs
        self.attr_spec = AttrSpec('', '')
        self.focus_nav = AttrSpec('h12', '')
        self.focus_ins = AttrSpec('h160', '')

        # Build widget stack
        self.title = TitleBar(self.name)
        self.group_foot = GroupFoot(self.group)
        self.body = urwid.SimpleFocusListWalker(self.tasks)
        self.list_box = ListBox(self.body)
        self.list_frame = Frame(self.list_box,
                                header=self.title,
                                footer=self.group_foot)
        self.line_box = LineBox(self.list_frame)
        self.line_attr = AttrMap(self.line_box, self.attr_spec, self.focus_nav)
        super().__init__(self.line_attr)
コード例 #3
0
    def __init__(self,
                 title,
                 enum_type,
                 starting_value,
                 policy=RadioPolicy.VERTICAL):
        self.selected_value = starting_value
        self.enum_type = enum_type

        self.radio_group = []
        for choice in enum_type:
            RadioButton(self.radio_group,
                        label=choice.name.capitalize(),
                        state=choice is starting_value)

        rows = [[Text(("header", title))]]

        if policy is RadioPolicy.VERTICAL:
            for radio in self.radio_group:
                rows.append([radio])
        else:
            col = []
            for radio in self.radio_group:
                col.append(radio)
            rows.append(col)

        super().__init__(rows)
        self._w = LineBox(self._w)
コード例 #4
0
    def build_widgets(self):

        instructions = Text("Remove services from {}".format(
            self.machine.hostname))

        self.machine_widget = MachineWidget(self.machine,
                                            self.controller,
                                            show_hardware=True)

        def show_remove_p(cc):
            md = self.controller.get_assignments(cc)
            for atype, ms in md.items():
                hostnames = [m.hostname for m in ms]
                if self.machine.hostname in hostnames:
                    return True
            return False

        actions = [(show_remove_p, 'Remove', self.do_remove)]

        self.services_list = ServicesList(self.controller,
                                          actions,
                                          actions,
                                          machine=self.machine)

        close_button = AttrMap(Button('X', on_press=self.close_pressed),
                               'button_secondary', 'button_secondary focus')
        p = Pile([
            GridFlow([close_button], 5, 1, 0, 'right'), instructions,
            Divider(), self.machine_widget,
            Divider(), self.services_list
        ])

        return LineBox(p, title="Remove Services")
コード例 #5
0
 def __init__(self, msg=None, height=10):
     if not msg:
         msg = "Processing."
     listbox = ListBox([Text(msg)])
     box_adapter = BoxAdapter(listbox, height=height)
     linebox = LineBox(box_adapter, title="Info")
     super().__init__(AttrWrap(linebox, 'dialog'))
コード例 #6
0
 def _create_text(self):
     self.text = []
     for line in self.HELP_TEXT:
         self._insert_line(line)
     return LineBox(BoxAdapter(
         ScrollableListBox(self.text),
         height=20),
         title='Help \u21C5 Scroll (ESC) Close')
コード例 #7
0
ファイル: keyboard.py プロジェクト: mattlknight/subiquity
 def __init__(self, keyboard_detector, step):
     # step is an instance of pc105.Step
     self.keyboard_detector = keyboard_detector
     self.step = step
     lb = LineBox(
         Pile([('pack', Text("")),
               ('pack', UrwidPadding(self.make_body(), left=2, right=2)),
               ('pack', Text(""))]), _("Keyboard auto-detection"))
     super().__init__(lb)
コード例 #8
0
    def __init__(self, text: str, palette: str, callback: Callable):
        connect_signal(self, CLICK_SIGNAL, callback)

        widget = LineBox(
            AttrMap(Text(f"[{text}]", align="center"), "default", palette))
        super().__init__(widget)

        # Glitch
        self._w.base_widget._selectable = True
コード例 #9
0
 def __init__(self, parent, ssids):
     self.parent = parent
     button = cancel_btn(_("Cancel"), on_press=self.do_cancel)
     ssid_list = [menu_btn(label=ssid, on_press=self.do_network)
                  for ssid in ssids]
     p = Pile([BoxAdapter(ListBox(ssid_list), height=10),
               Padding.fixed_10(button)])
     box = LineBox(p, title="Select a network")
     super().__init__(box)
コード例 #10
0
ファイル: network.py プロジェクト: fgimenez/subiquity
 def __init__(self, step_count, cancel_func):
     self.cancel_func = cancel_func
     button = cancel_btn(on_press=self.do_cancel)
     self.bar = ProgressBar(normal='progress_incomplete',
                     complete='progress_complete',
                     current=0, done=step_count)
     box = LineBox(Pile([self.bar,
                         Padding.fixed_10(button)]),
                   title="Applying network config")
     super().__init__(box)
コード例 #11
0
ファイル: shutdown.py プロジェクト: tomconte/conjure-up
 def __init__(self):
     message = "Conjure-up is shutting down, please wait."
     box = Padding.center_45(
         LineBox(
             Pile([
                 Padding.line_break(""),
                 Text(message, align="center"),
                 Padding.line_break(""),
             ])))
     super().__init__(Filler(box, valign="middle"))
コード例 #12
0
 def __init__(self, step_count, cancel_func):
     self.cancel_func = cancel_func
     button = cancel_btn(_("Cancel"), on_press=self.do_cancel)
     self.bar = ProgressBar(normal='progress_incomplete',
                            complete='progress_complete',
                            current=0,
                            done=step_count)
     box = LineBox(Pile([self.bar, button_pile([button])]),
                   title=_("Applying network config"))
     super().__init__(box)
コード例 #13
0
def main():
    background = AttrMap(SolidFill(' '), 'basic')
    pwdialog = PasswordDialog().compose()
    box = AttrMap(LineBox(pwdialog), 'blackongrey')
    window = Overlay(box, background, 'center', 30, 'middle', 10)

    mainloop = MainLoop(window,
                        unhandled_input=callback,
                        palette=simple_colours)
    mainloop.run()
コード例 #14
0
    def _build_widget(self, **kwargs):
        # Charm selections
        num_of_items, charm_sel = self._insert_charm_selections()

        # Control buttons
        buttons = self._insert_buttons()

        return LineBox(BoxAdapter(ListBox([charm_sel,
                                           Divider(), buttons]),
                                  height=num_of_items + 2),
                       title="Add unit")
コード例 #15
0
ファイル: filesystem.py プロジェクト: raharper/subiquity
 def __init__(self, parent, controller):
     self.parent = parent
     self.controller = controller
     pile = Pile([
         UrwidPadding(Text(confirmation_text), left=2, right=2),
         button_pile([
             cancel_btn(_("No"), on_press=self.cancel),
             danger_btn(_("Continue"), on_press=self.ok)]),
         Text(""),
         ])
     lb = LineBox(pile, title=_("Confirm destructive action"))
     super().__init__(lb)
コード例 #16
0
ファイル: keyboard.py プロジェクト: tbille/subiquity
 def __init__(self, loop):
     spinner = Spinner(loop, style='dots')
     spinner.start()
     text = _("Applying config")
     # | text |
     # 12    34
     self.width = len(text) + 4
     super().__init__(
         LineBox(Pile([
             ('pack', Text(' ' + text)),
             ('pack', spinner),
         ])))
コード例 #17
0
ファイル: manager.py プロジェクト: kuralabs/coral-dashboard
    def __init__(self):
        self._body = WidgetPlaceholder(
            Pile([
                Filler(
                    Text(
                        'Coral Dashboard Initialized\n'
                        'Waiting for agent ...',
                        align='center',
                    ), ),
            ]))
        self._wrapper = LineBox(
            self._body,
            title=self.DEFAULT_TITLE.format(version=__version__),
        )

        self.palette = ()
        self.topmost = MessageShower(
            self._wrapper,
            width=self.DEFAULT_MESSAGE_WIDTH,
            height=self.DEFAULT_MESSAGE_HEIGHT,
        )
        self.tree = OrderedDict()
コード例 #18
0
 def _init_widgets(self, names):
     self.names = names
     self.widgets = self._create_widgets()
     self.walker = ExpadableListWalker(self.widgets)
     self.listbox = ListBox(self.walker)
     self.view = LineBox(self.listbox,
                         tlcorner='',
                         tline='',
                         lline='',
                         trcorner='',
                         blcorner='',
                         rline='│',
                         bline='',
                         brcorner='')
コード例 #19
0
ファイル: selector.py プロジェクト: tbille/subiquity
 def __init__(self, parent, cur_index):
     self.parent = parent
     group = []
     for i, option in enumerate(self.parent._options):
         if option.enabled:
             btn = _PopUpButton(option.label, state=(i == cur_index))
             connect_signal(btn, 'click', self.click, i)
             group.append(AttrWrap(btn, 'menu_button', 'menu_button focus'))
         else:
             btn = Text("    " + option.label)
             group.append(AttrWrap(btn, 'info_minor'))
     list_box = ListBox(group)
     list_box.base_widget.focus_position = cur_index
     super().__init__(LineBox(list_box))
コード例 #20
0
class Record(WidgetWrap):
    """Render details about a single test case."""

    def __init__(self, repository):
        self._repository = repository
        self._log = Text("")
        self._box = LineBox(self._log)
        self._bind()
        super(Record, self).__init__(self._box)

    def _bind(self):
        self._repository.on_record_start += self._update_title
        self._repository.on_record_progress += self._update_logs

    def _update_title(self, repository, record):
        self._box.set_title(record.id)
        self._log.set_text("")

    def _update_logs(self, repository, record):

        log = ""
        traceback = ""

        for name, detail in record.details.items():
            text = detail.as_text().strip()
            if detail.content_type.subtype == "x-log":
                log += text
            elif detail.content_type.subtype == "x-traceback":
                # XXX Figure out how to get the timestamp from the original
                #     subunit packet, instead of letting LogRecord create
                #     a local timestamp.
                log_record = LogRecord(
                    name, ERROR, None, None, text, None, None)
                traceback += defaultFormatter.format(log_record)

        self._log.set_text(log + traceback)
コード例 #21
0
 def __init__(self, parent, cur_index):
     self.parent = parent
     group = []
     for i, option in enumerate(self.parent._options):
         if option[1]:
             btn = _PopUpButton(option[0], state=i==cur_index)
             connect_signal(btn, 'click', self.click, i)
             group.append(AttrWrap(btn, 'menu_button', 'menu_button focus'))
         else:
             btn = Text("    " + option[0])
             group.append(AttrWrap(btn, 'info_minor'))
     pile = Pile(group)
     pile.set_focus(group[cur_index])
     fill = Filler(pile, valign=TOP)
     super().__init__(LineBox(fill))
コード例 #22
0
    def __init__(self, text, palette, callback):
        """
        @text:  The text of show in the button.
        @palette:  A valid palette name to apply on the button.  See @TUI::palette
        @callback:  The callback to call when the button is clicked.
        """

        widget = LineBox(AttrMap(Text("[{}]".format(text), align="center"),
                                 "default", palette))
        super(Button, self).__init__(widget)
        connect_signal(self, TUISignal.CLICK, callback)

        # Very important!  This is not documented in urwid's
        # documentation!  Without this, the button would only text.
        self._w.base_widget._selectable = True
コード例 #23
0
 def __init__(self, row, snap):
     self.row = row
     self.closed = False
     text = _("Fetching info for {} failed").format(snap.name)
     # | text |
     # 12    34
     self.width = len(text) + 4
     retry = other_btn(label=_("Try again"), on_press=self.load)
     cancel = cancel_btn(label=_("Cancel"), on_press=self.close)
     super().__init__(
         LineBox(
             Pile([
                 ('pack', Text(' ' + text)),
                 ('pack', button_pile([retry, cancel])),
             ])))
コード例 #24
0
 def __init__(self, parent):
     self.parent = parent
     spinner = Spinner(parent.controller.loop, style='dots')
     spinner.start()
     text = _("Fetching SSH keys...")
     button = cancel_btn(label=_("Cancel"), on_press=self.cancel)
     # | text |
     # 12    34
     self.width = len(text) + 4
     super().__init__(
         LineBox(
             Pile([
                 ('pack', Text(' ' + text)),
                 ('pack', spinner),
                 ('pack', button_pile([button])),
             ])))
コード例 #25
0
ファイル: widgets.py プロジェクト: pdtopdog/piwheels
 def __init__(self, title, message):
     yes_button = FixedButton('Yes')
     no_button = FixedButton('No')
     connect_signal(yes_button, 'click', lambda btn: self._emit('yes'))
     connect_signal(no_button, 'click', lambda btn: self._emit('no'))
     super().__init__(
         LineBox(
             Pile([
                 ('pack', Text(message)),
                 Filler(Columns([
                     ('pack', AttrMap(yes_button, 'button', 'inv_button')),
                     ('pack', AttrMap(no_button, 'button', 'inv_button')),
                 ],
                                dividechars=2),
                        valign='bottom')
             ]), title))
コード例 #26
0
 def __init__(self, gui, description):
     self.progress_bar = ProgressBar('progress_empty',
                                     'progress_done',
                                     satt='progress_progress')
     self.id_text = Text('')
     self.eta_text = Text('', align='right')
     title = Text(' {} '.format(description), align='center')
     self.progress_widget = AttrMap(
         LineBox(
             Columns([
                 title, ('weight', 2, self.progress_bar), self.id_text,
                 self.eta_text
             ])), 'box')
     gui.progress.append(self.progress_widget)
     self.gui = gui
     gui.redraw()
コード例 #27
0
 def __init__(self, parent, aio_loop, msg, task_to_cancel):
     self.parent = parent
     self.spinner = Spinner(aio_loop, style='dots')
     self.spinner.start()
     self.closed = False
     # | text |
     # 12    34
     self.width = len(msg) + 4
     widgets = [
         ('pack', Text(' ' + msg)),
         ('pack', self.spinner),
     ]
     if task_to_cancel is not None:
         self.task_to_cancel = task_to_cancel
         cancel = cancel_btn(label=_("Cancel"), on_press=self.close)
         widgets.append(('pack', button_pile([cancel])))
     super().__init__(LineBox(Pile(widgets)))
コード例 #28
0
ファイル: urwid_test.py プロジェクト: kkospit/simplemaze
def move(key):
    # основная функция в mazegame
    game.move(key)
    # нашли выход
    if game.row == game.mazeclass.height - 2 and game.col == game.mazeclass.width - 2:
        global game_over
        game_over = True

        # запустим перевод в текст
        full_map = game.mazeclass.maze_to_string(None, 1, 1,
                                                 game.mazeclass.height,
                                                 game.mazeclass.width)
        text = Text("Лабиринт пройден!\n" + full_map, align="center")
        main_widget.original_widget = LineBox(Filler(text, valign="middle"))

    # изменяем описание места и меняем доступные кнопки
    change_main_widgets()
コード例 #29
0
 def __init__(self, parent, snap, loop):
     self.parent = parent
     self.spinner = Spinner(loop, style='dots')
     self.spinner.start()
     self.closed = False
     text = _("Fetching info for {}").format(snap.name)
     # | text |
     # 12    34
     self.width = len(text) + 4
     cancel = cancel_btn(label=_("Cancel"), on_press=self.close)
     super().__init__(
         LineBox(
             Pile([
                 ('pack', Text(' ' + text)),
                 ('pack', self.spinner),
                 ('pack', button_pile([cancel])),
             ])))
コード例 #30
0
ファイル: urwid_test.py プロジェクト: kkospit/simplemaze
def show_copybook(body):
    listbox = ListBox([*body])
    main_widget.original_widget = Overlay(LineBox(listbox),
                                          box,
                                          align="center",
                                          width=62,
                                          height=31,
                                          valign="middle")

    #меняем фокус на последний зарисованный участок лабиринта
    listbox.change_focus((20, 20),
                         len(body) - 1,
                         offset_inset=0,
                         coming_from=None,
                         cursor_coords=None,
                         snap_rows=None)
    button_power.overlay = 1