def _tab(self, content, attr):
     p = urwid.Text(content)
     p = urwid.Padding(p, align="left", width=("relative", 100))
     p = urwid.AttrWrap(p, attr)
     return p
Example #2
0
 def prepare_ssh_list_elements(self):
     ssh_keys = []
     for key in get_public_ssh_keys():
         ssh_keys.append(urwid.AttrWrap(SelectableText(os.path.basename(key)), 'ssh_copy', 'ssh_copy_focus'))
     return ssh_keys
Example #3
0
 def editbx(elem):
     edit_boxes.append(elem)
     return urwid.AttrWrap(elem, 'editbx')
Example #4
0
def password_prompt(password_text, editor, max_prompt_padding):
    password = urwid.Text(password_text, "center")
    return urwid.Columns([(len(password_text), password),
                          (max_prompt_padding - len(password_text), urwid.Text("")),
                          urwid.AttrWrap(editor, "password-editor")])
Example #5
0
 def __init__(self, blackHole):
     #Define global access for other classes, ugly!!
     set_blackHole(blackHole)
     self.blackHole = blackHole
     self.user = blackHole.data.user
     self.palette = [
         ('body', 'black', 'light gray'),  # Normal Text
         ('focus', 'light green', 'black', 'standout'),  # Focus
         ('head', 'yellow', 'dark gray', 'standout'),  # Header
         ('foot', 'light gray', 'dark gray'),  # Footer Separator
         ('key', 'light green', 'dark gray', 'underline'),
         ('title', 'white', 'black', 'bold'),
         ('environmentMark', 'dark blue', 'light gray', 'bold'),
         ('focus_error', 'dark red', 'black'),
         ('error', 'dark red', 'light gray', 'bold'),
         ('footer_msg', 'yellow', 'dark gray'),
     ]
     self.footer_text = [
         ('footer_msg', _("Move:")),
         " ",
         ('key', _("up")),
         ",",
         ('key', _("down")),
         ",",
         ('key', _("home")),
         ",",
         ('key', _("end")),
         ",",
         ('key', _("left")),
         ",",
         ('key', _("w/Mouse")),
         " ",
         ('footer_msg', _("Expand:")),
         " ",
         ('key', "space"),
         ",",
         ('key', "click"),
         " ",
         ('footer_msg', _("Select:")),
         " ",
         ('key', "enter"),
         ",",
         ('key', _("DoubleClick")),
         "  ",
         ('footer_msg', _("Quit:")),
         " ",
         ('key', "q"),
         "  ",
         ('footer_msg', "\nChat:"),
         " ",
         ('key',
          "c" if self.blackHole.settings.chat_enabled else _("Disabled")),
         "  ",
         ('footer_msg', "By:"),
         " ",
         ('key', "%s [%s]" %
          (black_hole.get_author(), black_hole.get_author_email())),
     ]
     self.quit = False
     try:
         self.listbox = urwid.ListBox(EnvironmentWalker(self.user))
     except Exception as e:
         raise Exception("[!] %s" % e.message)
     self.listbox.offset_rows = 1
     self.header = urwid.AttrWrap(urwid.Text(self.footer_text), 'foot')
     self.header.set_align_mode('center')
     self.footer = urwid.AttrWrap(urwid.Text(self.footer_text), 'foot')
     self.footer.set_align_mode('center')
     self.view = urwid.Frame(urwid.AttrWrap(self.listbox, 'body'),
                             header=urwid.AttrWrap(self.header, 'head'),
                             footer=self.footer)
    if key in ('m', 'M') and movement_distance != "slot":
        set_movement_distance(min(movement_distance, 50))
        move_in_direction(types.Point(0, 0, -1))
    if key == "up":
        move_in_direction(types.Point(0, 1, 0))
    if key == "down":
        move_in_direction(types.Point(0, -1, 0))
    if key == "left":
        move_in_direction(types.Point(-1, 0, 0))
    if key == "right":
        move_in_direction(types.Point(1, 0, 0))


text_header = (u"TubeCheckout Calibration")

header = urwid.AttrWrap(urwid.Text(text_header), 'header')

pos_txt = urwid.Text(('reverse', u"Current position: "))

movement_distance_txt = urwid.Text(('reverse', u"Movement distance: "))

message = urwid.Text(('reverse', u""))

num_key_expl = ", ".join(
    [f"{k}:{movement_distances[k]}mm" for k in movement_distances])
keyboard = urwid.Text(f"""\
KEYBOARD SHORTCUTS:

Number keys - set movement distance: {num_key_expl}

Arrow keys - move horizontally by movement distance
Example #7
0
	def main(self):
		global DATA

		text_header = (u"OpenChronos config  \u2503  "
					   u"UP / DOWN / PAGE UP / PAGE DOWN scroll.  F8 aborts.")

		self.list_content = list_content = []
		for key,field in DATA.iteritems():
			# generate gui forms depending on type
			self.generate_widget(key,field)

		# rescan widgets and disable/enable them based on their dependencies
		for key,wid in WIDMAP.iteritems():
			if not hasattr(wid, '_widget'):
				continue
			wid = wid._widget
			if isinstance(wid, urwid.Edit):
				val = wid.get_edit_text()
			elif isinstance(wid, urwid.CheckBox):
				val = wid.get_state()
			else:
				continue
			widget_changed_callback(wid, val)

		def ok_pressed(*args, **kwargs):
			raise urwid.ExitMainLoop()

		def abort_pressed(*args, **kwargs):
			sys.exit(0)

		list_content.append(urwid.Divider(div_char=u"\u2550", top=1, bottom=1))
		list_content.append(
		urwid.Padding(urwid.GridFlow(
			[urwid.AttrWrap(urwid.Button("Save", ok_pressed), 'opt','optsel'),
			 urwid.AttrWrap(urwid.Button("Abort", abort_pressed), 'opt','optsel')],
			15, 4, 4, 'center'),
			('fixed left',4), ('fixed right',3)))


		header = urwid.AttrWrap(urwid.Text(text_header), 'header')
		walker = HelpListWalker(self, list_content)
		listbox = urwid.ListBox(walker)
		self.help_widget = urwid.Text("")
		footer = urwid.AttrWrap(self.help_widget, 'footer')
		frame = urwid.Frame(urwid.AttrWrap(listbox, 'body'), header=header, footer=footer)

		screen = urwid.raw_display.Screen()
		palette = [
			('header',	'white',	'dark red', 	'bold'),
			('info',	'black',	'dark cyan'),
			('body',	'black',	'dark gray'),
			('optsel',	'white',	'dark blue'),
			('opt',		'black',	'light gray'),
			('optd',	'black',	'dark gray'),
			]


		def unhandled(key):
			if key == 'f8':
				#raise urwid.ExitMainLoop()
				sys.exit(0)

		urwid.MainLoop(frame, palette, screen,
			unhandled_input=unhandled).run()
Example #8
0
 def __init__(self, node):
     super(StatWidget, self).__init__(node)
     self._w = urwid.AttrWrap(self._w, None, StatisticsViewer.focus_map)
Example #9
0
def radio_button(g, l, fn):
    """ Inheriting radio button of urwid """
    w = urwid.RadioButton(g, l, False, on_state_change=fn)
    w = urwid.AttrWrap(w, 'button normal', 'button select')
    return w
Example #10
0
 def create_header_widgets(self):
     self.header = urwid.Text("Press ESC to exit")
     self.header = urwid.AttrWrap(self.header, "header")
Example #11
0
 def set_main_view(self, *widgets):
     self.main_view = urwid.ListBox(urwid.SimpleListWalker([self.title, self.top_menu_columns, *widgets]))
     self.main_view = urwid.Frame(header=self.header, body=self.main_view)
     self.main_view = urwid.AttrWrap(self.main_view, "body")
Example #12
0
    def main_window(self):
        # initiating the graphs
        self.graphs = OrderedDict()
        self.summaries = OrderedDict()

        for source in self.controller.sources:
            source_name = source.get_source_name()
            color_pallet = source.get_pallet()
            alert_pallet = source.get_alert_pallet()
            self.graphs[source_name] = BarGraphVector(
                source, color_pallet,
                len(source.get_sensor_list()),
                self.graphs_menu.active_sensors[source_name],
                alert_colors=alert_pallet
            )
            if self.controller.script_hooks_enabled:
                source.add_edge_hook(
                    self.controller.script_loader.load_script(
                        source.__class__.__name__, HOOK_INTERVAL)
                )  # Invoke threshold script every 30s

            self.summaries[source_name] = SummaryTextList(
                self.graphs[source_name].source,
                self.summary_menu.active_sensors[source_name],
            )

        # Check if source is available and add it to a dict of visible graphs
        # and summaries.
        # All available summaries are always visible
        self.visible_graphs = OrderedDict(
            (key, val) for key, val in self.graphs.items() if
            val.get_is_available())

        # Do not show the graph if there is no selected sensors
        for key in self.graphs.keys():
            if not any(self.graphs_menu.active_sensors[key]):
                del self.visible_graphs[key]

        self.visible_summaries = OrderedDict(
            (key, val) for key, val in self.summaries.items() if
            val.get_is_available())

        cpu_stats = self._generate_cpu_stats()
        graph_controls = self._generate_graph_controls()
        summaries = self._generate_summaries()

        text_col = ViListBox(urwid.SimpleListWalker(cpu_stats +
                                                    graph_controls +
                                                    [summaries]))

        vline = urwid.AttrWrap(urwid.SolidFill(u'|'), 'line')
        widget = urwid.Columns([('fixed', 20, text_col),
                                ('fixed', 1, vline),
                                ('weight', 2, self.graph_place_holder)],
                               dividechars=0, focus_column=0)

        widget = urwid.Padding(widget, ('fixed left', 1), ('fixed right', 1))
        self.main_window_w = widget

        base = self.main_window_w.base_widget[0].body
        self.summary_widget_index = len(base) - 1
        logging.debug("Pile index: %s", self.summary_widget_index)

        return self.main_window_w
Example #13
0
 def callback():
     assert isinstance(value, str)
     frame.footer = urwid.AttrWrap(
         urwid.Text(["Enter ?...: ", value]), "header")
Example #14
0
def main(qualname: str):
    if not isinstance(qualname, str):
        from types import ModuleType

        if isinstance(qualname, ModuleType):
            qualname = qualname.__name__
        else:
            qualname = qualname.__module__ + "." + qualname.__qualname__

    # import json
    # data = json.loads(file_path.read_text())
    # data

    def gen_content(blob, frame):
        R = Renderer(frame, walk, gen_content, stack)
        doc = []
        doc.append(blank)
        if blob.signature:
            doc.append(Text([("signature", blob.signature)]))

        for k, v in blob.content.items():

            if not v.empty():
                if k not in ["Summary", "Extended Summary"]:
                    doc.append(Text([("section", k)]))
                # doc.append(Text("<Blank InnerSec>"))
                doc.append(blank)
                doc.append(R.render(v))
        if blob.see_also:
            doc.append(Text(("section", "See Also")))
            doc.append(blank)
            for s in blob.see_also:
                doc.append(urwid.Padding(R.render(s), left=2))
                doc.append(blank)

        if not blob.example_section_data.empty():
            doc.append(Text(("section", "Examples")))
            doc.append(blank)
            doc.append(R.render(blob.example_section_data))

        if blob.item_type and ("module" in blob.item_type):
            for s in blob.arbitrary:
                doc.append(R.render(s))

        if blob.backrefs:
            doc.append(Text(("section", "Back References")))
            doc.append(Text("All the following items Refer to this page:"))
            for b in blob.backrefs:
                doc.append(
                    urwid.Padding(
                        TextWithLink([
                            Link("link", b.path,
                                 (lambda x: lambda: R.cb(x))(b))
                        ]),
                        # TextWithLink([Link("param", b, lambda: R.cb(b))]),
                        left=2,
                    ))
        doc = dedup(doc)

        doc.append(blank)
        doc.append(blank)
        doc.append(blank)

        def cb(value):
            def callback():
                assert isinstance(value, str)
                frame.footer = urwid.AttrWrap(
                    urwid.Text(["Enter ?...: ", value]), "header")

            return callback

        return doc

    stack = []

    walk = urwid.SimpleListWalker([])
    listbox = urwid.ListBox(walk)
    frame = urwid.Frame(urwid.AttrWrap(listbox, "body"))  # , header=header)
    frame.footer = urwid.AttrWrap(
        urwid.Text(
            "q: quit | ?: classic IPython help screen | Arrow/Click: focus links & navigate | enter: follow link"
        ),
        "header",
    )

    found = guess_load(qualname, walk, gen_content, stack, frame)
    if not found:
        return False

    # header = urwid.AttrWrap(Text("numpy.geomspace"), "header")
    #    'black'
    #    'dark red'
    #    'dark green'
    #    'brown'
    #    'dark blue'
    #    'dark magenta'
    #    'dark cyan'
    #    'light gray'
    #    'dark gray'
    #    'light red'
    #    'light green'
    #    'yellow'
    #    'light blue'
    #    'light magenta'
    #    'light cyan'
    #    'white'

    palette = [
        ("body", "default", "default", "standout"),
        ("reverse", "light gray", "black"),
        ("header", "white", "dark blue", "bold"),
        ("bb", "bold", "default", ("standout", "underline")),
        ("important", "dark red,bold", "default", ("standout", "underline")),
        ("editfc", "white", "dark blue", "bold"),
        ("editbx", "light gray", "dark blue"),
        ("editcp", "black", "light gray", "standout"),
        ("bright", "dark gray", "light gray", ("bold", "standout")),
        ("buttn", "black", "dark cyan"),
        ("buttnf", "white", "dark blue", "bold"),
        ("verbatim", "brown", "", "bold"),
        # ("link", "dark red,bold", "default", ("standout", "underline")),
        ("local", "light magenta", "", "bold"),
        ("link", "dark green,underline", "", "bold"),
        ("link_selected", "dark green,bold", "", "bold"),
        ("link_selected", "black,bold", "white"),
        ("link-broken", "dark red,strikethrough", "", "bold"),
        ("type", "dark cyan", "", "bold"),
        ("signature", "dark cyan,bold", "", "bold"),
        ("param", "dark blue", "", "bold"),
        ("section", "dark magenta,bold", "", "bold"),
        ("unknown", "white", "dark red", "bold"),
        ("directive", "white", "dark red", "bold"),
        ("math", "dark magenta,italics", "", "bold"),
        # pygments
        ("pyg-o", "dark blue", "", "bold"),  # operator (+, .)
        ("pyg-mi", "dark red", "", "bold"),  # number literal 12, 55
        ("pyg-kc", "dark green", "", "bold"),
        ("pyg-nb", "white", "", "bold"),
        ("pyg-kn", "dark green", "", "bold"),  # keyword import
        ("pyg-nn", "dark blue", "", "bold"),  # name
        ("pyg-k", "dark green", "", "bold"),  # keyword as
        ("pyg-s2", "dark green", "",
         "bold"),  # strings, like "this is a string s2"
        ("pyg-sa", "dark green", "",
         "bold"),  # string brefixes like b"", u"" r""
    ]

    # use appropriate Screen class
    if urwid.web_display.is_web_request():
        screen = urwid.web_display.Screen()
    else:
        screen = urwid.raw_display.Screen()
    found = True

    def unhandled(key):
        nonlocal found
        if key == "?":
            found = False
            raise urwid.ExitMainLoop()
        elif key == "q":
            raise urwid.ExitMainLoop()
        elif key == "backspace":
            if len(stack) >= 2:
                stack.pop()
                old = stack.pop()
                guess_load(old, walk, gen_content, stack, frame)

    urwid.MainLoop(frame, palette, screen, unhandled_input=unhandled).run()
    return found
Example #15
0
    def __init__(self):
        self.conn_status = False
        self.tcount = 0  # Counter for connection twirl indicator

        self.size = ui.get_cols_rows()
        # Happy screen saying that you can't do anything because we're scanning
        # for networks.  :-)
        self.screen_locker = urwid.Filler(
            urwid.Text(
                ('important', _('Scanning networks... stand by...')),
                align='center'
            )
        )
        self.no_wlan = urwid.Filler(
            urwid.Text(
                ('important', _('No wireless networks found.')),
                align='center'
            )
        )
        self.TITLE = _('Wicd Curses Interface')
        self.WIRED_IDX = 1
        self.WLESS_IDX = 3

        header = urwid.AttrWrap(urwid.Text(self.TITLE, align='right'),
                                'header')
        self.wiredH = urwid.Filler(urwid.Text(_('Wired Networks')))
        self.list_header = urwid.AttrWrap(
            urwid.Text(gen_list_header()), 'listbar'
        )
        self.wlessH = NSelListBox([
            urwid.Text(_('Wireless Networks')),
            self.list_header
        ])

        # Init this earlier to make update_status happy
        self.update_tag = None

        # FIXME: This should be two variables
        self.focusloc = [1, 0]

        # These are empty to make sure that things go my way.
        wiredL, wlessL = [], []

        self.frame = None
        self.diag = None

        self.wiredCB = urwid.Filler(WiredComboBox(wiredL))
        self.wlessLB = urwid.ListBox(wlessL)
        self.update_netlist(force_check=True, firstrun=True)

        # Keymappings proposed by nanotube in #wicd
        keys = [('H', _('Help'), None),
                ('right', _('Config'), None),
                # ('  ', '         ', None),
                ('K', _('RfKill'), None),
                ('C', _('Connect'), None),
                ('D', _('Disconn'), None),
                ('R', _('Refresh'), None),
                ('P', _('Prefs'), None),
                ('I', _('Hidden'), None),
                ('A', _('About'), None),
                ('Q', _('Quit'), loop.quit)]

        self.primaryCols = OptCols(keys, self.handle_keys)
        self.status_label = urwid.AttrWrap(urwid.Text(''), 'important')
        self.footer2 = urwid.Columns([self.status_label])
        self.footerList = urwid.Pile([self.primaryCols, self.footer2])

        self.frame = urwid.Frame(self.thePile,
                                 header=header,
                                 footer=self.footerList)
        self.wiredCB.get_body().build_combobox(self.frame, ui, 3)

        # Init the other columns used in the program
        self.init_other_optcols()

        self.frame.set_body(self.thePile)
        # Booleans gallore!
        self.prev_state = False
        self.connecting = False
        self.screen_locked = False
        # Whether the screen is locked beneath a dialog
        self.do_diag_lock = False
        self.diag_type = 'none'  # The type of dialog that is up
        self.scanning = False

        self.pref = None

        self.update_status()
Example #16
0
def button(t, fn, data=None):
    w = urwid.Button(t, fn, data)
    w = urwid.AttrWrap(w, 'button normal', 'button select')
    return w
Example #17
0
 def footer_view(self) -> Any:
     text_header = self.get_random_help()
     return urwid.AttrWrap(urwid.Text(text_header), "footer")
Example #18
0
    def __init__(self, output_prefix=None):
        self.exit_message = None

        self.output_prefix = output_prefix

        text_header = (u"Command Generation for 'rosbag record' ")
        buttons = OrderedDict()
        buttons['quit'] = urwid.Button(u"Quit(ESC/q)", self.on_quit)
        buttons['save'] = dialog.PopUpButton(u"Save(F2)",
                                             self.on_save,
                                             prompt_text=u"Input file name:",
                                             default_text=u"record.sh")
        buttons['mark'] = urwid.Button(u"Mark all(F3)", self.on_mark_all)
        buttons['unmark'] = urwid.Button(u"Unmark all(F4)", self.on_unmark_all)
        buttons['refresh'] = urwid.Button(u"Refresh(F5)", self.on_refresh)
        self.buttons = buttons

        # blank = urwid.Divider()

        header = urwid.AttrWrap(urwid.Text(text_header, align='center'),
                                'header')

        button_bar = urwid.GridFlow([
            urwid.AttrWrap(btn, 'buttn', 'buttnf')
            for (key, btn) in buttons.iteritems()
        ], 18, 3, 1, 'left')
        status_bar = urwid.AttrWrap(urwid.Text(u""), 'footer')
        footer = urwid.Pile([button_bar, status_bar])

        self.listwalker = urwid.SimpleListWalker(
            self.create_listbox_from_ros())
        listbox = urwid.ListBox(self.listwalker)
        body = urwid.AttrWrap(listbox, 'body')

        self.frame = urwid.Frame(body=body, header=header, footer=footer)

        self.frame_focus_table = dict()
        self.frame_focus_table[body] = 'footer'
        self.frame_focus_table[footer] = 'body'

        palette = [
            ('body', 'white', 'black', 'standout'),
            ('reverse', 'light gray', 'black'),
            ('header', 'white', 'dark blue', 'bold'),
            ('footer', 'black', 'light gray'),
            ('important', 'dark blue', 'light gray', ('standout',
                                                      'underline')),
            ('editfc', 'white', 'dark blue', 'bold'),
            ('editbx', 'light gray', 'dark blue'),
            ('editcp', 'black', 'light gray', 'standout'),
            ('bright', 'dark gray', 'light gray', ('bold', 'standout')),
            ('buttn', 'black', 'light cyan'),
            ('buttnf', 'white', 'dark blue', 'bold'),
            ('popbg', 'white', 'dark gray'),
        ]

        self.show_msg = status_bar.set_text

        screen = urwid.raw_display.Screen()

        self.mainloop = urwid.MainLoop(self.frame,
                                       palette,
                                       screen,
                                       unhandled_input=self.unhandled,
                                       pop_ups=True)
Example #19
0
def menu(par,
         options,
         prompt,
         default=None,
         title=None,
         any_ok=False,
         order=None,
         extras=None,
         multiple=False,
         empty_ok=False,
         ui=None,
         oklabel='Ok',
         cancellabel='Cancel',
         quitlabel=None):
    if not extras:
        extras = []
    else:
        extras = list(extras)

    if not default:
        default = ''

    if title:
        title = '%s: %s' % (VERSION, title)
    else:
        title = VERSION

    if isinstance(options, dict):
        options = options.copy()
        # Convert to a list
        if order:
            olist = []
            for key in order:
                if key in options:
                    olist.append((key, options[key]))
                    del options[key]

            # Append anything out of order
            options = list(options.items())
            options.sort()
            for option in options:
                olist.append(option)
            options = olist
        else:
            options = list(options.items())
            options.sort()

    opts = []
    for option, desc in options:
        if desc:
            opts.append((option, re.sub(r'\s+', ' ', desc)))
        else:
            opts.append((option, desc))
    options = opts

    if multiple:
        widgets = [(urwid.CheckBox(option, state=(option == default)), desc
                    or '') for (option, desc) in options]
        box = checklistdialog(par,
                              widgets,
                              height=('relative', 80),
                              title=title)
        if quitlabel:
            box.add_buttons([(oklabel, 0), (cancellabel, -1), (quitlabel, -2)])
        else:
            box.add_buttons([(oklabel, 0), (cancellabel, -1)])
        result, chosen = box.main(ui)
        if result < 0:
            # We return None to differentiate a Cancel/Quit from no selection, []
            return None
        return chosen

    # Single menu option only
    def label_button(option, desc):
        return option

    widgets = []
    rlist = []
    for option, desc in options:
        if option == '---':
            # Separator is just a text label
            b = urwid.Text(desc)
            b = urwid.AttrWrap(b, 'scrolllabel')
            desc = ''
        else:
            b = urwid.RadioButton(rlist,
                                  label_button(option, desc),
                                  state=(option == default))
            b.exitcode = option
            b = urwid.AttrWrap(b, 'selectable', 'focus')
        widgets.append((b, desc))

    box = listdialog(par,
                     widgets,
                     height=('relative', 80),
                     title=title,
                     buttonwidth=12)
    if quitlabel:
        box.add_buttons([(oklabel, 0), (cancellabel, -1), (quitlabel, -2)])
    else:
        box.add_buttons([(oklabel, 0), (cancellabel, -1)])
    focus = 0
    if default:
        for i, opt in enumerate(options):
            if opt[0] == default:
                focus = i
                break

    result, chosen = box.main(ui)
    if result < 0:
        return result

    return chosen
Example #20
0
 def log_view(self):
     footer_txt = self.mainloop.game.display_log()
     footer = urwid.Text(footer_txt)
     box = LogBody(urwid.Filler(footer))
     body = urwid.AttrWrap(box, 'body')
     return body
Example #21
0
def username_prompt(username_text, editor, max_prompt_padding):
    username = urwid.Text(username_text, "center")
    return urwid.Columns([(len(username_text), username),
                          (max_prompt_padding - len(username_text), urwid.Text("")),
                          urwid.AttrWrap(editor, "editor")])
Example #22
0
 def initial_footer_widget(self):
     """Create the initial footer widget to be updated later."""
     return urwid.AttrWrap(
         urwid.Text(self.current_page.page_status, align='right'),
         'footer'
     )
Example #23
0
def border(w):
    return urwid.AttrWrap(urwid.LineBox(w), 'border')
Example #24
0
 def text(self, text):
     self._name = text
     self._w = urwid.AttrWrap(urwid.Text(self._name), 'head')
Example #25
0
 def create_disabled_radio_button(self, name):
     w = urwid.Text('    ' + name)
     w = urwid.AttrWrap(w, 'button disabled')
     return w
Example #26
0
 def __init__(self, name):
     self._name = name
     super().__init__(urwid.AttrWrap(urwid.Text(self._name), 'head'))
Example #27
0
 def attr_wrapper(elem):
     return urwid.AttrWrap(elem, *attrs)
Example #28
0
    def __init__(self, return_func, available_namespaces_dict):

        self.available_namespaces_dict = available_namespaces_dict
        self.selection_ch_box = [
            urwid.CheckBox("{:30}{:30}{}".format(namespace['name'],
                                                 namespace['status'],
                                                 namespace['age']))
            for namespace in available_namespaces_dict
        ]
        self.text_deletion_result = urwid.Text(u"")

        blank = urwid.Divider()
        listbox_content = [
            blank,
            urwid.WidgetWrap(urwid.Divider("=", 1)),
            urwid.Padding(urwid.Text(u"Namespace Removal"),
                          left=2,
                          right=2,
                          min_width=20),
            urwid.WidgetWrap(urwid.Divider("*", 0, 1)),
            urwid.Padding(
                urwid.Text(u"Use space/enter to mark Namespaces to remove"),
                left=2,
                right=2,
                min_width=20),
            blank,

            # Display namespaces block
            urwid.Padding(urwid.Pile([
                urwid.Text("    {:30}{:30}{}".format("NAME", "STATUS", "AGE")),
                urwid.Pile([
                    urwid.AttrWrap(namespace, 'buttn', 'buttnf')
                    for namespace in self.selection_ch_box
                ], ),
            ]),
                          left=2,
                          right=2,
                          min_width=10),
            blank,
            urwid.Padding(urwid.GridFlow([
                urwid.AttrWrap(urwid.Button("Cancel", on_press=self.on_cancel),
                               'buttn', 'buttnf'), blank,
                urwid.AttrWrap(
                    urwid.Button("Delete Selected Namespaces",
                                 on_press=self.on_delete), 'buttn', 'buttnf')
            ], 20, 1, 8, 'left'),
                          left=2,
                          right=2,
                          min_width=20,
                          align='left'),
            blank,
            urwid.Padding(self.text_deletion_result,
                          left=2,
                          right=2,
                          min_width=20),
        ]

        listbox = urwid.ListBox(urwid.SimpleListWalker(listbox_content))

        self.return_func = return_func
        self.main_window = urwid.LineBox(urwid.AttrWrap(listbox, 'body'))
Example #29
0
 def set_active(self, val):
     h = urwid.Text("Command Help")
     style = "heading" if val else "heading_inactive"
     self.header = urwid.AttrWrap(h, style)
Example #30
0
 def __init__(self, txt):
     txt = txt.encode("string-escape")
     w = urwid.Edit(edit_text=txt, wrap="any", multiline=True)
     w = urwid.AttrWrap(w, "editfield")
     common.WWrap.__init__(self, w)