Python urwid.WidgetWrap() Examples
The following are 30
code examples of urwid.WidgetWrap().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
urwid
, or try the search function
.
Example #1
Source File: base.py From ceph-ansible-copilot with GNU Lesser General Public License v2.1 | 6 votes |
def __init__(self, text, app, align='left'): """ @param text: same as urwid.Text's text parameter @param align: same as urwid.Text's align parameter """ self._was_focused = False self.text = text self.app = app urwid.WidgetWrap.__init__(self, urwid.Text(text, align=align)) if 'X' in self.text[:3]: self._selected = True else: self._selected = False data_field = self.text[3:].split() hostname = data_field[1] self.roles = self.app.hosts[hostname].roles self._mon = True if 'mon' in self.roles else False self._rgw = True if 'rgw' in self.roles else False self._osd = True if 'osd' in self.roles else False
Example #2
Source File: home.py From terminal-leetcode with MIT License | 6 votes |
def __init__(self, data, marks, sel=True): self.sel = sel self.id = data.id self.data = data lockbody = 'body' if not self.data.locked else 'lock' pass_symbol = u'' if self.data.submission_status == 'ac': pass_symbol = u'\u2714' elif self.data.submission_status == 'notac': pass_symbol = u'\u2718' text = str(self.data.id) mark = make_mark(marks, self.data.id) self.item = [ (4, urwid.AttrWrap(urwid.Text(text), lockbody, 'focus')), (2, urwid.AttrWrap(urwid.Text(pass_symbol), lockbody, 'focus')), (10, urwid.AttrWrap(urwid.Text(mark), 'hometag', 'focus')), urwid.AttrWrap(urwid.Text('%s ' % data.title + (u'\u2605'if self.data.favorite else '')), lockbody, 'focus'), (15, urwid.AttrWrap(urwid.Text('%s' % data.acceptance), lockbody, 'focus')), (15, urwid.AttrWrap(urwid.Text('%s' % data.difficulty), lockbody, 'focus')), ] w = urwid.Columns(self.item) urwid.WidgetWrap.__init__(self, w)
Example #3
Source File: base.py From stig with GNU General Public License v3.0 | 6 votes |
def __init__(self, data, cells): self._data = data # Info of torrent/tracker/file/peer/... as mapping self._cells = cells # Group instance that combines widgets horizontally # Create focusable or unfocusable item widget if self.columns_focus_map is not NotImplemented: item_widget = urwid.AttrMap( urwid.AttrMap(cells, attr_map=None, focus_map=self.columns_focus_map), self.palette_unfocused, self.palette_focused ) else: item_widget = urwid.AttrMap(cells, self.palette_unfocused) urwid.WidgetWrap.__init__(self, item_widget) # Initialize cell widgets self.update(data)
Example #4
Source File: result.py From terminal-leetcode with MIT License | 6 votes |
def make_unified_error_view(self, error_title): blank = urwid.Divider() status_header = urwid.AttrWrap(urwid.Text('Run Code Status: '), 'body') status = urwid.AttrWrap(urwid.Text(error_title), 'hometag') columns = urwid.Columns([(17, status_header), (30, status)]) column_wrap = urwid.WidgetWrap(columns) if 'last_testcase' in self.result: result_header = urwid.Text('--- Run Code Result: ---', align='center') your_input_header = urwid.Text('Last executed input:') your_input = urwid.Text(self.result['last_testcase']) list_items = [ result_header, blank, column_wrap, blank, your_input_header, your_input, ] else: list_items = [ result_header, blank, column_wrap, ] self._append_stdout_if_non_empty(list_items) return urwid.Padding(urwid.ListBox(urwid.SimpleListWalker(list_items)), left=2, right=2)
Example #5
Source File: result.py From terminal-leetcode with MIT License | 6 votes |
def make_runtime_error_view(self): blank = urwid.Divider() status_header = urwid.AttrWrap(urwid.Text('Run Code Status: '), 'body') status = urwid.AttrWrap(urwid.Text('Runtime Error'), 'hometag') columns = urwid.Columns([(17, status_header), (20, status)]) column_wrap = urwid.WidgetWrap(columns) result_header = urwid.Text('--- Run Code Result: ---', align='center') error_header = urwid.Text('Runtime Error Message:') error_message = urwid.Text(self.result['runtime_error']) your_input_header = urwid.Text('Last input:') your_input = urwid.Text(self.result['last_testcase']) list_items = [ result_header, blank, column_wrap, blank, error_header, error_message, blank, your_input_header, your_input, ] self._append_stdout_if_non_empty(list_items) return urwid.Padding(urwid.ListBox(urwid.SimpleListWalker(list_items)), left=2, right=2)
Example #6
Source File: result.py From terminal-leetcode with MIT License | 6 votes |
def make_compile_error_view(self): blank = urwid.Divider() status_header = urwid.AttrWrap(urwid.Text('Run Code Status: '), 'body') status = urwid.AttrWrap(urwid.Text('Compile Error'), 'hometag') columns = urwid.Columns([(17, status_header), (20, status)]) column_wrap = urwid.WidgetWrap(columns) result_header = urwid.Text('--- Run Code Result: ---', align='center') your_input_header = urwid.Text('Your input:') your_input = urwid.Text('') your_answer_header = urwid.Text('Your answer:') your_answer = urwid.Text(self.result['compile_error']) expected_answer_header = urwid.Text('Expected answer:') expected_answer = urwid.Text('Unkown Error') list_items = [ result_header, blank, column_wrap, blank, your_input_header, your_input, blank, your_answer_header, your_answer, blank, expected_answer_header, expected_answer ] self._append_stdout_if_non_empty(list_items) return urwid.Padding(urwid.ListBox(urwid.SimpleListWalker(list_items)), left=2, right=2)
Example #7
Source File: views.py From zulip-terminal with Apache License 2.0 | 6 votes |
def __init__(self, controller: Any, question: Any, success_callback: Callable[[], bool]): self.controller = controller self.success_callback = success_callback yes = urwid.Button('Yes', self.exit_popup_yes) no = urwid.Button('No', self.exit_popup_no) yes._w = urwid.AttrMap(urwid.SelectableIcon( 'Yes', 4), None, 'selected') no._w = urwid.AttrMap(urwid.SelectableIcon( 'No', 4), None, 'selected') display_widget = urwid.GridFlow([yes, no], 3, 5, 1, 'center') wrapped_widget = urwid.WidgetWrap(display_widget) prompt = urwid.LineBox( urwid.ListBox( urwid.SimpleFocusListWalker( [question, urwid.Divider(), wrapped_widget] ))) urwid.Overlay.__init__(self, prompt, self.controller.view, align="left", valign="top", width=self.controller.view.LEFT_WIDTH + 1, height=8)
Example #8
Source File: statusbar.py From binch with MIT License | 5 votes |
def __init__(self, text, view): urwid.WidgetWrap.__init__(self, None) self.view = view self.commandline = CommandLine() self.default_text = text self.update_status() signals.redraw_status.connect(self.sig_redraw_status)
Example #9
Source File: chat.py From Discurses with MIT License | 5 votes |
def __init__(self, discord_client, channels, send_channel, name): self.discord = discord_client self.channels = channels self.send_channel = send_channel self.ui = self.discord.ui self.channel_names = discurses.processing \ .shorten_channel_names(channels, 14) self.name = name # Public widgets self.w_channel_selector = SendChannelSelector(self) self.w_message_list = MessageListWidget(self.discord, self) self.w_message_edit = MessageEditWidget(self.discord, self) self.w_member_list = MemberList(self) self.w_server_tree = ServerTree(self) self.w_statusbar = Statusbar(self) # Public fields self.show_member_list = True self.show_server_tree = True # Setup layout widgets self._setup_layout() HasModal.__init__(self, self._w_layout) urwid.WidgetWrap.__init__(self, self._w_placeholder) self.set_focus(ChatWindow.FocusTarget.SERVER_TREE)
Example #10
Source File: server_tree.py From Discurses with MIT License | 5 votes |
def __init__(self, node): self._node = node self._innerwidget = None self.is_leaf = False self.expanded = False widget = self.get_indented_widget() urwid.WidgetWrap.__init__(self, widget)
Example #11
Source File: base.py From ceph-ansible-copilot with GNU Lesser General Public License v2.1 | 5 votes |
def __init__(self, parent): self.parent = parent urwid.WidgetWrap.__init__(self, self.render_page)
Example #12
Source File: base.py From ceph-ansible-copilot with GNU Lesser General Public License v2.1 | 5 votes |
def __init__(self, item, long_description): self.item = item self.desc = long_description w = urwid.Columns([ (DataRow.item_col_size, urwid.Text(self.item)), urwid.Text(self.desc)]) self._w = urwid.AttrMap(w, "body", "bkgnd_white") urwid.WidgetWrap.__init__(self, self._w)
Example #13
Source File: base.py From ceph-ansible-copilot with GNU Lesser General Public License v2.1 | 5 votes |
def __init__(self, bottom_w=None, complete=0): self.bottom_w = bottom_w self.done = 0 self.complete = complete urwid.WidgetWrap.__init__(self, self.render_page)
Example #14
Source File: defaultFrame.py From TerminusBrowser with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, welcome=False, test=False): self.headerString = 'TerminusBrowser' self.footerStringRight = f'' self.url = 'Welcome Screen' if welcome: welcomeText = pyfiglet.figlet_format('TerminusBrowser') + '\nRecent Commits:\n' if not test: r = requests.get('https://api.github.com/repos/wtheisen/TerminusBrowser/commits') data = r.json() count = 0 for cData in data: commit = cData['commit'] cleanMessage = commit['message'].replace('\r', '').replace('\n\n', '\n') welcomeText += f'\n {commit["author"]["name"]}: {cleanMessage}' if count < 4: count += 1 else: break self.contents = urwid.Text(welcomeText, 'center') else: self.contents = urwid.Text('') self.contents = urwid.Filler(self.contents) urwid.WidgetWrap.__init__(self, self.contents)
Example #15
Source File: abstractFrame.py From TerminusBrowser with BSD 3-Clause "New" or "Revised" License | 5 votes |
def load(self): self.startTime = time.time() self.loader() self.endTime = time.time() self.footerStringRight = f'Parsed {self.parsedItems} items in {(self.endTime - self.startTime):.4f}s' # self.contents MUST BE SET in self.loader() if self.contents == None: raise ValueError(object) urwid.WidgetWrap.__init__(self, self.contents)
Example #16
Source File: splitTracker.py From TerminusBrowser with BSD 3-Clause "New" or "Revised" License | 5 votes |
def buildUrwidFromSplits(splitList): log.debug(type(splitList) is View) if type(splitList) is Column: return urwid.Columns([buildUrwidFromSplits(x) for x in splitList.widgets]) elif type(splitList) is Row: return urwid.Pile([buildUrwidFromSplits(x) for x in splitList.widgets]) elif type(splitList) is View: return urwid.WidgetWrap(urwid.LineBox(splitList.frame))
Example #17
Source File: statusbar.py From binch with MIT License | 5 votes |
def update_status(self): if self.view.disasmblr.arch == 'ARM' and isinstance(self.view.disasmlist._w.focus, view.DisassembleInstruction): if self.view.disasmlist._w.focus.isthumb: mode = "[Thumb]" else: mode = "[ ARM ]" self.status = urwid.Columns([ urwid.WidgetWrap(urwid.Text(self.default_text)), ('fixed', 20, urwid.WidgetWrap(urwid.Text(mode))) ]) else: self.status = urwid.WidgetWrap(urwid.Text(self.default_text)) self.status = urwid.AttrMap(self.status, 'status') self._w = urwid.Pile([self.status, self.commandline])
Example #18
Source File: statusbar.py From binch with MIT License | 5 votes |
def __init__(self): urwid.WidgetWrap.__init__(self, None) self.clear() signals.set_prompt.connect(self.sig_prompt) signals.set_prompt_yn.connect(self.sig_prompt_yn) signals.set_message.connect(self.sig_message) self.prompt_callback = False self.prompt_yn_callback = False
Example #19
Source File: view.py From binch with MIT License | 5 votes |
def __init__(self, dList): urwid.WidgetWrap.__init__(self, None) self.update_list(dList)
Example #20
Source File: view.py From binch with MIT License | 5 votes |
def __init__(self, instr, disasmblr, view): urwid.WidgetWrap.__init__(self, None) self.instruction = instr self.hexcode = list(self.instruction.bytes) self.isthumb = disasmblr.is_thumb_instr(instr) self._editbox = None self._hexeditbox = None self.edit_mode = False self.hex_edit_mode = False self.disasmblr = disasmblr self.view = view self.repeat = 1 self.mode_plain()
Example #21
Source File: details.py From stig with GNU General Public License v3.0 | 5 votes |
def mksection(title, width, items): # Setting class variable 'title = title' below produces "NameError: name # 'title' is not defined" title_, width_ = title, width class Section(urwid.WidgetWrap): title = title_ width = width_ def __init__(self): value_widgets = {} needed_keys = set() rows = [] label_width = max(len(item.label) for item in items) for item in items: label_w = urwid.Text(item.label.rjust(label_width)) value_w = urwid.Text('') value_widgets[item] = value_w rows.append(urwid.Columns([('pack', label_w), ('pack', urwid.Text(': ')), value_w])) needed_keys.update(item.needed_keys) self._value_widgets = value_widgets self.needed_keys = needed_keys super().__init__(urwid.Pile(rows)) def update(self, torrent): for item,value_w in self._value_widgets.items(): value_w.set_text(item.human_readable(torrent)) return Section
Example #22
Source File: oanda_console.py From oandapyV20-examples with MIT License | 5 votes |
def __init__(self, t): self.t = t w = urwid.AttrMap(self.t, 'body', 'focus') urwid.WidgetWrap.__init__(self, w) if not self.MENU: self.MENU = [u'{instrument} Cmds: ', ('close button', u'C'), u') close position ', ('quit button', u'Q'), u') to quit.']
Example #23
Source File: oanda_console.py From oandapyV20-examples with MIT License | 5 votes |
def __init__(self, txt): self.t = urwid.Text(txt) w = urwid.AttrMap(self.t, 'body', 'focus') urwid.WidgetWrap.__init__(self, w)
Example #24
Source File: tui.py From socli with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, description): urwid.WidgetWrap.__init__(self, UnicodeText('')) self.description = description self.set_description()
Example #25
Source File: tui.py From socli with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, answers): urwid.WidgetWrap.__init__(self, UnicodeText('')) self._selectable = True # so that we receive keyboard input self.answers = answers self.index = 0 self.set_answer()
Example #26
Source File: tui.py From socli with BSD 3-Clause "New" or "Revised" License | 5 votes |
def keypress(self, size, key): """ Overrides keypress in superclass, so don't fall for the trap! size parameter is needed! """ if key in {'down', 'n', 'N'}: self.answer_text.next_ans() elif key in {'up', 'b', 'B'}: self.answer_text.prev_ans() elif key in {'o', 'O'}: import webbrowser display_header.event('browser', "Opening in your browser...") webbrowser.open(self.url) elif key == 'left': global question_post global question_page question_post = None if question_page is None: sys.exit(0) else: MAIN_LOOP.widget = question_page elif key == 'window resize': screen_height, screen_width = subprocess.check_output(['stty', 'size']).split() if self.screenHeight != screen_height: self._invalidate() answer_frame = self.make_frame(self.data) urwid.WidgetWrap.__init__(self, answer_frame) elif key in {'q', 'Q'}: sys.exit(0)
Example #27
Source File: tui.py From socli with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, data): """ Construct the Question Page. :param data: tuple of (answers, question_title, question_desc, question_stats, question_url) """ answer_frame = self.make_frame(data) urwid.WidgetWrap.__init__(self, answer_frame)
Example #28
Source File: treewidgets.py From pycopia with Apache License 2.0 | 5 votes |
def __init__(self, txt, handle_keypress=None): self._handle_keypress = handle_keypress urwid.WidgetWrap.__init__(self, Text(txt))
Example #29
Source File: widgets.py From pycopia with Apache License 2.0 | 5 votes |
def construct_example_tree(selectable_nodes=True): class FocusableText(urwid.WidgetWrap): """Selectable Text used for nodes in our example""" def __init__(self, txt): t = urwid.Text(txt) w = urwid.AttrMap(t, 'body', 'focus') urwid.WidgetWrap.__init__(self, w) def selectable(self): return selectable_nodes def keypress(self, size, key): return key # define root node tree = (FocusableText('ROOT'), []) # define some children c = g = gg = 0 # counter for i in range(4): subtree = (FocusableText('Child %d' % c), []) # and grandchildren.. for j in range(2): subsubtree = (FocusableText('Grandchild %d' % g), []) for k in range(3): leaf = (FocusableText('Grand Grandchild %d' % gg), None) subsubtree[1].append(leaf) gg += 1 # inc grand-grandchild counter subtree[1].append(subsubtree) g += 1 # inc grandchild counter tree[1].append(subtree) c += 1 return tree
Example #30
Source File: widgets.py From pycopia with Apache License 2.0 | 5 votes |
def __init__(self, name): t = urwid.Text(name) w = urwid.AttrMap(t, 'body', 'focus') urwid.WidgetWrap.__init__(self, w)