Exemple #1
0
    def __init__(self):
        self.screen = Screen()
        self.screen.set_input_timeouts(max_wait=0)
        self.steps = GridFlow([], 20, 2, 1, 'left')
        self.progress = SimpleFocusListWalker([])
        self.log = SimpleFocusListWalker([])

        self.widget = AttrMap(
            LineBox(Pile([
                ('fixed', 6, AttrMap(Filler(self.steps), 'default')),
                ('fixed', 1, Filler(Divider('\u2500'))),
                ('fixed', 3, ListBox(self.progress)),
                AttrMap(LineBox(ListBox(self.log), title='Message log'),
                        'default')
            ]),
                    title='Indico 1.2 -> 2.0 migration'), 'global_frame')

        self.screen.register_palette(
            [('green', 'light green', ''), ('white', 'white', ''),
             ('red', 'dark red', ''), ('yellow', 'yellow', ''),
             ('progress_empty', 'black',
              'light gray'), ('progress_progress', 'light cyan', 'light gray'),
             ('progress_done', 'black', 'light cyan'),
             ('box', 'white', 'dark gray'), ('step_done', 'light green', ''),
             ('step_working', 'dark gray',
              ''), ('global_frame', 'light cyan',
                    ''), ('fill', 'light cyan', 'dark cyan'),
             ('done', 'white', 'dark green'), ('eta', 'yellow', 'dark gray')] +
            generate_urwid_palette(PALETTE))
Exemple #2
0
    def _build_widget(self, **kwargs):
        total_items = []
        for _item in self.radio_items.keys():
            desc = AttrWrap(
                Text("  {}".format(
                    self.radio_items[_item][1])), 'input', 'input focus')
            total_items.append(
                AttrWrap(self.radio_items[_item][0], 'input', 'input focus'))
            total_items.append(AttrWrap(desc, 'input'))
            total_items.append(Divider('-'))

        self.input_lbox = ListBox(SimpleListWalker(total_items[:-1]))
        self.add_buttons()

        self.container_box_adapter = BoxAdapter(self.input_lbox,
                                                len(total_items))
        self.container_lbox = ListBox(
            [self.container_box_adapter,
             Divider(),
             self.btn_pile])

        return LineBox(
            BoxAdapter(self.container_lbox,
                       height=len(total_items) + 3),
            title=self.title)
Exemple #3
0
    def __init__(self,
                 choice_callback=None,
                 command_callback=None,
                 help_callback=None):

        self.palette = [
            ('brick', 'light red', 'black'),
            ('rubble', 'yellow', 'black'),
            ('wood', 'light green', 'black'),
            ('concrete', 'white', 'black'),
            ('stone', 'light cyan', 'black'),
            ('marble', 'light magenta', 'black'),
            ('jack', 'dark gray', 'white'),
            ('msg_info', 'white', 'black'),
            ('msg_err', 'light red', 'black'),
            ('msg_debug', 'light green', 'black'),
        ]

        self.choice_callback = choice_callback
        self.command_callback = command_callback
        self.help_callback = help_callback

        self.screen = None
        self.loop = None
        self.called_loop_stop = False
        self.reactor_stop_fired = False

        self.quit_flag = False
        self.edit_msg = "Make selection ('q' to quit): "
        self.roll_list = SimpleListWalker([])
        self.game_log_list = SimpleListWalker([])
        self.choices_list = SimpleListWalker([])

        self.state_text = SimpleListWalker([Text('Connecting...')])

        self.edit_widget = Edit(self.edit_msg)
        self.roll = ListBox(self.roll_list)
        self.game_log = ListBox(self.game_log_list)
        self.choices = ListBox(self.choices_list)
        self.state = ListBox(self.state_text)

        self.left_frame = Pile([
            LineBox(self.state),
            (13, LineBox(self.choices)),
        ])

        self.right_frame = Pile([LineBox(self.game_log), LineBox(self.roll)])

        self.state.set_focus(len(self.state_text) - 1)

        self.columns = Columns([('weight', 0.75, self.left_frame),
                                ('weight', 0.25, self.right_frame)])
        self.frame_widget = Frame(footer=self.edit_widget,
                                  body=self.columns,
                                  focus_part='footer')

        self.exc_info = None
Exemple #4
0
    def __init__(self,
                 height,
                 directory=".",
                 file="",
                 attr=(None, None),
                 show_hidden=False):
        """
        height -- height of the directory list and the file list
        directory, file -- default selection
        attr -- (inner selectable widgets, selected widgets)
        show_hidden -- If True, hidden files are shown by default.
        """

        self.directory = abspath(directory)
        self.file = ""
        self.attr = attr
        self.height = height
        self.show_hidden = show_hidden

        # Create dummy widgets for directory and file display:
        self.dir_widget = AttrWrap(
            BoxAdapter(ListBox([self._blank]), self.height), self.attr[0])
        self.file_widget = AttrWrap(
            BoxAdapter(ListBox([self._blank]), self.height), self.attr[0])

        columns = Columns([self.dir_widget, self.file_widget], 1)

        # Selection widget:
        self.select_widget = AttrWrap(Edit("", ""), self.attr[0], self.attr[1])

        # Buttons and checkbox:
        button_widgets = [
            AttrWrap(Button(button, self._action), attr[0], attr[1])
            for button in ["OK", "Cancel"]
        ]
        button_grid = GridFlow(button_widgets, 12, 2, 1, 'center')

        button_cols = Columns([
            CheckBox(self.SHOW_HIDDEN_TEXT, self.show_hidden, False,
                     self._toggle_hidden), button_grid
        ])

        self.outer_widget = Pile([
            columns, self._blank,
            Text(self.SELECTION_TEXT), self.select_widget, self._blank,
            button_cols
        ])

        self.update_widgets()

        WidgetWrap.__init__(self, self.outer_widget)
Exemple #5
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)
Exemple #6
0
    def __init__(self, model, signal, selected_disk):
        log.debug('AddPartitionView: selected_disk=[{}]'.format(selected_disk))
        self.model = model
        self.signal = signal
        self.selected_disk = selected_disk
        self.disk_obj = self.model.get_disk(selected_disk)

        self.partnum = IntegerEditor(caption="",
                                     default=self.disk_obj.lastpartnumber + 1)
        self.size_str = _humanize_size(self.disk_obj.freespace)
        self.size = StringEditor(caption="".format(self.size_str))
        self.mountpoint = MountEditor(caption="", edit_text="/")
        self.fstype = Selector(opts=self.model.supported_filesystems)
        body = [
            Columns([
                ("weight", 0.2,
                 Text("Adding partition to {}".format(self.disk_obj.devpath),
                      align="right")), ("weight", 0.3, Text(""))
            ]),
            Padding.line_break(""),
            self._container(),
            Padding.line_break(""),
            Padding.fixed_10(self._build_buttons())
        ]
        partition_box = Padding.center_50(ListBox(body))
        super().__init__(partition_box)
Exemple #7
0
    def __init__(self, executor_widgets):
        self.log_widget = ScrollingLog()

        self.latest_stats = LatestStats()
        self.cumulative_stats = CumulativeStats()

        stats_pane = Pile([(WEIGHT, 0.333, self.latest_stats),
                           (WEIGHT, 0.667, self.cumulative_stats)])

        self.graphs = ThreeGraphs()
        self.logo = TaurusLogo()

        ordered_widgets = sorted(executor_widgets, key=lambda x: x.priority)
        right_widgets = ListBox(
            SimpleListWalker([Pile([x, Divider()]) for x in ordered_widgets]))
        widget_pile = Pile([
            (7, self.logo),
            right_widgets,
        ])

        log_block = Pile([(1, Filler(Divider('─'))), self.log_widget])

        right_pane = Pile([(WEIGHT, 0.667, widget_pile),
                           (WEIGHT, 0.333, log_block)])

        columns = [(WEIGHT, 0.25, self.graphs), (WEIGHT, 0.50, stats_pane),
                   (WEIGHT, 0.25, right_pane)]
        super(TaurusConsole, self).__init__(columns)
Exemple #8
0
    def __init__(self, num_rows=20, w=(14, 14, 18, 16, 16, 16, 20)):
        """
            @method __init__
            Initializes the widget
        """
        self.m_process_list = ProcessList(w)
        self.prev_sort_item = None

        self.w_status = HeaderButton('Status', 'status', self.handle_click)
        self.w_pid = HeaderButton('PID', 'pid', self.handle_click)
        self.w_name = HeaderButton('Name', 'name', self.handle_click)
        self.w_cpu = HeaderButton('CPU %', 'cpu_perc', self.handle_click)
        self.w_mem = HeaderButton('MEM %', 'mem_perc', self.handle_click)
        self.w_up = HeaderButton('Uptime', 'uptime', self.handle_click)
        self.w_pname = HeaderButton('Process', 'pname', self.handle_click)

        self.w_cpu.activate()
        self.prev_sort_item = self.w_cpu

        self.header_buttons = h = [
            self.w_status, self.w_pid, self.w_name, self.w_cpu, self.w_mem,
            self.w_up, self.w_pname
        ]

        m_header = AttrMap(
            Columns([('fixed', w[i], h[i]) for i in range(0, len(h))]),
            'invert')
        m_lb = ListBox(
            SimpleListWalker(
                [m_header, BoxAdapter(self.m_process_list, num_rows)]))
        super(ProcessTable, self).__init__(m_lb, None)
        self.update()
 def __init__(self, model, signal, iface):
     self.model = model
     self.signal = signal
     self.ifname = iface
     self.iface = self.model.get_interface(self.ifname)
     self.is_gateway = False
     self.gateway_input = StringEditor(caption="")  # FIXME: ipaddr_editor
     self.address_input = StringEditor(caption="")  # FIXME: ipaddr_editor
     self.subnet_input = StringEditor(caption="")  # FIXME: ipaddr_editor
     self.error = Text("", align='center')
     self.nameserver_input = \
         StringEditor(caption="")  # FIXME: ipaddr_editor
     self.searchdomains_input = \
         StringEditor(caption="")  # FIXME: ipaddr_editor
     self.set_as_default_gw_button = Pile(
         self._build_set_as_default_gw_button())
     body = [
         Padding.center_79(self._build_iface_inputs()),
         Padding.line_break(""),
         Padding.center_79(self.set_as_default_gw_button),
         Padding.line_break(""),
         Padding.center_90(Color.info_error(self.error)),
         Padding.line_break(""),
         Padding.fixed_10(self._build_buttons())
     ]
     super().__init__(ListBox(body))
Exemple #10
0
    def build_widgets(self):
        readme_files = glob(os.path.join(self.spell_dir, 'README.*'))
        if len(readme_files) == 0:
            self.readme_w = Text("No README found for bundle.")
        else:
            readme_file = readme_files[0]
            if len(readme_files) != 1:
                utils.warning("Unexpected: {} files matching README.*"
                              "- using {}".format(len(readme_files),
                                                  readme_file))
            with open(readme_file) as rf:
                rlines = [Text(l) for l in rf.readlines()]
                self.readme_w = BoxAdapter(ListBox(rlines),
                                           self.initial_height)

        ws = [
            Text("About {}:".format(self.spell_name)),
            Padding.right_50(
                Color.button_primary(PlainButton("Continue", self.do_continue),
                                     focus_map='button_primary focus')),
            Padding.center(HR()),
            Padding.center(self.readme_w, left=2),
            Padding.center(HR()),
            Padding.center(
                Text("Use arrow keys to scroll text "
                     "and TAB to select the button."))
        ]

        self.pile = Pile(ws)
        return Padding.center_90(Filler(self.pile, valign="top"))
Exemple #11
0
    def __init__(self, tui, locator, device):
        super().__init__(tui)
        self.body.contents.append(
            (Text("Selected device \"{}\"".format(device)), ('pack', None)))
        fn = self.tui.controller.get_filename(locator)
        self.filename_txt = Text("Selected file \"{}\"".format(fn))
        self.body.contents.append((self.filename_txt, ('pack', None)))
        self.body.contents.append((Divider(), ('pack', None)))

        self.statuswidget = Pile([])
        self.body.contents.append((self.statuswidget, ('pack', None)))
        self.body.contents.append((Divider(), ('pack', None)))

        self.locator = locator
        self.device = device

        self.walker = SimpleFocusListWalker([])
        listbox = ListBox(self.walker)
        self.body.contents.append((listbox, ('weight', 1)))
        self.body.focus_position = 5
        self.add_hotkey('U', self.update, "update")
        self.add_hotkey('w', self.webcams, "webcams")
        self.add_hotkey('a', self.actions, "actions")
        self.status = defaultdict(str)
        self.update()
Exemple #12
0
 def __init__(self, model, signal, iface):
     self.model = model
     self.signal = signal
     self.iface = iface
     self.iface_obj = self.model.get_interface(iface)
     self._build_widgets()
     super().__init__(ListBox(self._build_body()))
Exemple #13
0
    def create_interface(self):
        self.screen = Screen()
        self.screen.start()

        self.screen.register_palette([
            ("title", "white", "dark blue", "standout"),
            ("line", "light gray", "black"),
            ("help", "white", "dark blue")]
        )

        self.body = ListBox(SimpleListWalker([]))
        self.lines = self.body.body

        self.title = Text(MAIN_TITLE)
        self.header = AttrWrap(self.title, "title")

        self.help = AttrWrap(
            Text(HELP_STRINGS["main"]),
            "help"
        )

        self.input = Edit(caption="%s> " % self.ircchannel)
        self.footer = Pile([self.help, self.input])

        self.top = Frame(self.body, self.header, self.footer)
Exemple #14
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'))
Exemple #15
0
    def __init__(self, tui, locator, device):
        super().__init__(tui)
        self.body.contents.append(
            (Text("Select file to load on \"{}\"".format(device)), ('pack',
                                                                    None)))
        self.body.contents.append((Divider(), ('pack', None)))
        self.device = device

        self.locator = locator
        self.device = device
        self.all_files = []

        def limit(regexp):
            self.regexp = regexp
            self.populate_list()

        def enter(edit_text):
            if len(self.walker) < 1:
                self.tui.pop_window()
                return
            button = self.walker[0]
            button.keypress(1, 'enter')

        editbox = CB_Edit("Limit (regexp): ", "", limit, enter)
        self.body.contents.append((editbox, ('pack', 1)))
        self.body.contents.append((Divider(), ('pack', 1)))

        self.walker = SimpleFocusListWalker([])
        listbox = ListBox(self.walker)
        self.body.contents.append((listbox, ('weight', 1)))
        self.body.focus_position = 2
        self.update()
        self.regexp = ".*"
Exemple #16
0
 def __init__(self, app, results, cb):
     self.app = app
     self.results = results
     self.cb = cb
     self.result_pile = [Padding.line_break("")]
     self.result_pile += [
         Padding.center_90(s) for s in self.build_results()
     ]
     super().__init__(ListBox(self.result_pile))
Exemple #17
0
def start(config):
    """Start the application and handle user input. Blocks until the application exits."""
    def item_chosen(button, server):
        global choice
        choice = server
        response = Text(
            [u'Connecting to: ',
             server.connection_string(), u'\n'])
        done = Button(u'Ok')
        urwid.connect_signal(done, 'click', exit_program)
        main.original_widget = Filler(
            Pile([response,
                  AttrMap(done, None, focus_map='reversed')]))

    def exit_program(button):
        raise urwid.ExitMainLoop()

    def unhandled(key):
        vim_map = {'h': 'left', 'j': 'down', 'k': 'up', 'l': 'right'}
        if key in vim_map.keys():
            list_box.keypress((0, 1), vim_map[key])
        elif key in ['left', 'right']:
            pass
        elif key in ['esc', 'q']:
            raise ExitMainLoop()

    body = [urwid.Text(u'\nServers'), Divider(u'-')]

    for server in config.get_servers():
        button = Button(server.name)
        urwid.connect_signal(button, 'click', item_chosen, server)
        body.append(AttrMap(button, None, focus_map='reversed'))

    list_box = ListBox(urwid.SimpleFocusListWalker(body))

    main = Padding(list_box, left=2, right=2)

    overlay = Overlay(main,
                      SolidFill(u'\N{MEDIUM SHADE}'),
                      align='center',
                      width=('relative', 60),
                      valign='middle',
                      height=('relative', 60),
                      min_width=20,
                      min_height=9)

    header = AttrMap(Text(u' ssh-menu'), 'header')
    footer = AttrMap(Text(u'this is the footer'), 'footer')

    frame = Frame(overlay, header=header, footer=footer)

    urwid.MainLoop(urwid.AttrMap(frame, 'body'),
                   palette=palette,
                   unhandled_input=unhandled).run()

    return choice
Exemple #18
0
 def __init__(self, model, signal):
     self.model = model
     self.signal = signal
     self.items = []
     self.body = [
         Padding.center_79(self._build_model_inputs()),
         Padding.line_break(""),
         Padding.fixed_10(self._build_buttons()),
     ]
     super().__init__(ListBox(self.body))
Exemple #19
0
 def __init__(self, signal):
     self.signal = signal
     self.body = [
         Padding.center_79(Text("This view is not yet implemented.")),
         Padding.line_break(""),
         Padding.center_79(Color.info_minor(Text("A place holder widget"))),
         Padding.line_break(""),
         Padding.center_79(self._build_buttons())
     ]
     super().__init__(ListBox(self.body))
Exemple #20
0
    def _build_widget(self, **kwargs):

        total_items = []
        for _item in self.input_items.keys():
            total_items.append(
                AttrWrap(self.input_items[_item], 'input', 'input focus'))
        self.input_lbox = ListBox(SimpleListWalker(total_items))

        # Add buttons
        self.add_buttons()
        self.container_box_adapter = BoxAdapter(self.input_lbox,
                                                len(total_items))
        self.container_lbox = ListBox(
            [self.container_box_adapter,
             Divider(), self.btn_pile])

        return LineBox(BoxAdapter(self.container_lbox,
                                  height=len(total_items) + 1 +
                                  len(self.btn_pile.contents)),
                       title=self.title)
Exemple #21
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")
Exemple #22
0
    def __init__(self, tui):
        super().__init__(tui)
        self.body.contents.append((Text("Available Webcams"), ('pack', None)))
        self.body.contents.append((Divider(), ('pack', None)))

        self.walker = SimpleFocusListWalker([])
        listbox = ListBox(self.walker)
        self.body.contents.append((listbox, ('weight', 1)))
        self.body.focus_position = 2
        self.add_hotkey('U', self.update, "update")
        self.update()
Exemple #23
0
 def __init__(self, common, cb):
     self.common = common
     self.cb = cb
     _pile = [
         Padding.center_90(Text("Choose a solution to get started:")),
         Padding.center_90(Divider("\N{BOX DRAWINGS LIGHT HORIZONTAL}")),
         Padding.center_90(self.build_menuable_items()),
         Padding.line_break(""),
         Padding.center_20(self.buttons())
     ]
     super().__init__(ListBox(_pile))
Exemple #24
0
 def __init__(self, signal, error_message):
     suggestion = "Check the installer log files for details and try again"
     self.signal = signal
     self.body = [
         Padding.center_79(Text(error_message)),
         Padding.line_break(""),
         Padding.center_79(Color.info_minor(Text(suggestion))),
         Padding.line_break(""),
         Padding.line_break(""),
         Padding.center_79(self._build_buttons())
     ]
     super().__init__(ListBox(self.body))
Exemple #25
0
 def __init__(self, walker, **kwargs):
     """
     :param walker: tree of widgets to be displayed.
         In case we are given a raw `TreeWalker`, it will be used though
         `TreeListWalker` which means no decoration.
     :type walker: TreeWalker or TreeListWalker
     """
     if not isinstance(walker, TreeListWalker):
         walker = TreeListWalker(walker)
     self._walker = walker
     self._outer_list = ListBox(walker)
     self.__super.__init__(self._outer_list)
Exemple #26
0
 def __init__(self, tree, focus=None):
     """
     :param tree: tree of widgets to be displayed.
     :type tree: Tree
     :param focus: initially focussed position
     """
     self._tree = tree
     self._walker = TreeListWalker(tree)
     self._outer_list = ListBox(self._walker)
     if focus is not None:
         self._outer_list.set_focus(focus)
     self.__super.__init__(self._outer_list)
    def __init__(self, track=None, clip=None):
        self.editing = clip or track

        self.header = Text(
            'Editing clip {}'.format(clip.name) if clip else
            'Adding new clip to {}'.format(track.name) if track else 'Editor')
        self.widgets = [EditorWidget(name, label, default)
             for name, label, default
             in self.editing.get_fields()] \
             if self.editing else []
        self.body = ListBox(SimpleFocusListWalker(self.widgets))

        WidgetWrap.__init__(self, Frame(self.body, self.header))
Exemple #28
0
    def render_component(self, props):
        def make_todo(id, completed, text):
            def on_click():
                props['on_todo_click'](id)

            return Todo(
                on_click=on_click,
                completed=completed,
                text=text,
            )

        return ListBox(
            SimpleListWalker([make_todo(**todo) for todo in props['todos']]))
Exemple #29
0
 def __init__(self, model, signal):
     self.model = model
     self.signal = signal
     self.volgroup = UsernameEditor(edit_text="", caption="")
     self.selected_disks = []
     body = [
         Padding.center_50(self._build_disk_selection()),
         Padding.line_break(""),
         Padding.center_50(self._build_lvm_configuration()),
         Padding.line_break(""),
         Padding.fixed_10(self._build_buttons())
     ]
     super().__init__(ListBox(body))
Exemple #30
0
 def __init__(self, model, signal, iface):
     self.model = model
     self.signal = signal
     self.iface = iface
     self.iface_obj = self.model.get_interface(iface)
     self.essid_input = StringEditor(caption="")
     self.psk_input = PasswordEditor(caption="")
     self.body = [
         Padding.center_79(self._build_iface_inputs()),
         Padding.line_break(""),
         Padding.fixed_10(self._build_buttons())
     ]
     super().__init__(ListBox(self.body))