我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用urwid.Columns()。
def __init__(self, initial_buttons): self.list_stack = [initial_buttons] self.all_styled_buttons = [urwid.AttrMap(b, None, 'reveal focus') for b in initial_buttons.items] self.list_walker = ChooseFromListWalker(self.all_styled_buttons, self) list_box = ChooseFromListBox(self.list_walker) column_array = convert_details_to_columns( initial_buttons.items[0].retrieve_important_details()) self.cols = urwid.Columns( [('weight', 1, column_array[0]), ('weight', 4, column_array[1])], ) self.detail_view = False self.base_title_text = self.list_stack[-1].items_title self.title = urwid.AttrMap(urwid.Text(self.base_title_text + " " + self.EMPTY_FILTER_TEXT), 'title') self.cols_title = urwid.AttrMap(urwid.Text(u'Attributes'), 'title') self.body = urwid.Pile([(2, urwid.Filler(self.title, valign='top')), list_box, ( 2, urwid.Filler(self.cols_title, valign='top')), self.cols]) self.before_detail = None self.filter_string = ""
def __init__(self, data, field_labels, btn_label, callbacks): self.app = data["app"] self.error = False self.fields, self.callbacks = [], callbacks for label in field_labels: self.fields.append(InputField(label, next_callback=self.next)) input_fields = urwid.Pile(self.fields) self.message_field = urwid.Text('') error_row = urwid.Columns([(17, urwid.Text('')), self.message_field]) buttons = [TextButton(btn_label, on_press=self.next)] if callbacks['back']: buttons.insert(0, TextButton('< Back', align='left', on_press=callbacks['back'])) footer = urwid.AttrMap(urwid.Columns(buttons), 'button') card = Card(urwid.Pile( [data["content"], input_fields, error_row]), footer=footer) urwid.WidgetWrap.__init__(self, card)
def __init__(self, title, cred, tests, data): self.app = None self.tester = data["tester"] urn = cred["nodelist"][0][0] + ":" + str(cred["nodelist"][0][1]) + ( "/" + (cred["database"]) if bool(cred["database"]) else "") self.data = {"title": title, "callback": data["callback"], "urn": urn, "num_tests": len(tests)} self.progress_text = urwid.Text( ('progress', '0/' + str(self.data["num_tests"]))) running_display = urwid.Columns( [(14, urwid.Text(('text', 'Running test'))), self.progress_text]) self.progress_bar = CustomProgressBar( 'progress', 'remaining', 0, self.data["num_tests"]) self.text_running = urwid.Text(('text', '')) box = urwid.BoxAdapter(urwid.Filler( self.text_running, valign='top'), 2) pile = urwid.Pile([running_display, self.progress_bar, DIV, box]) urwid.WidgetWrap.__init__(self, pile)
def __init__(self): self.game = Game() self._statusbar = urwid.Text(u'Ready') self.current_selection = Selection(None, None) self._tableau_columns = urwid.Columns([EmptyCardWidget() for _ in range(7)]) self._top_columns = urwid.Columns([ EmptyCardWidget(), EmptyCardWidget(), SpacerWidget(), EmptyCardWidget(), EmptyCardWidget(), EmptyCardWidget(), EmptyCardWidget(), ]) self._update_stock_and_waste() self._update_foundations() self._update_tableaus() self.main_layout = urwid.Pile([ self._top_columns, urwid.Divider(), self._tableau_columns, urwid.Divider(), self._statusbar, ])
def delete_tab(self, fname): files = self.display.file_names # make sure there is more than one file open if len(files) > 1: index = files.index(fname) if index < len(files)-1: # if not last in list new_name = files[index+1] else: # if last file in list new_name = files[index-1] # delete file and contents from master lists #del self.display.tab_info[fname] del files[index] del self.display.tabs[index] # reset the footer with new tab amount foot_col = urwid.Columns(self.display.tabs) foot = urwid.AttrMap(foot_col, 'footer') if self.display.layout: self.display.top.contents['header'] = (foot, None) else: self.display.top.contents['footer'] = (foot, None) self.switch_tabs(new_name) del self.display.tab_info[fname]
def __init__(self, pubpen): self.pubpen = pubpen self.exchange_entry = urwid.Text('(C)ommodity Exchange') self.port_entry = urwid.Text('(P)ort District') self.financial_entry = urwid.Text('(F)inancial') self.travel_entry = urwid.Text('(T)ravel') self.game_menu_entry = urwid.Text('(M)enu') self.menu_entries = urwid.Columns(( ('weight', 1, urwid.Divider(' ')), (len('(C)ommodity Exchange') + 4, self.exchange_entry), (len('(P)ort District') + 4, self.port_entry), (len('(F)inancial') + 4, self.financial_entry), (len('(T)ravel') + 4, self.travel_entry), (len('(M)enu') + 4, self.game_menu_entry), ('weight', 1, urwid.Divider(' ')), ), dividechars=1) super().__init__(self.menu_entries)
def __init__(self, pubpen, spacer=u'u2500'): self.pubpen = pubpen self.who = urwid.Text(u'\u2524 Name: \u251C') self.where = urwid.Text(u'\u2524 Location: \u251C') self.left = urwid.Columns([self.who]) self.right = urwid.Columns([self.where]) super().__init__((('pack', self.who), ('weight', 1, urwid.Divider(spacer)), ('pack', self.where), )) # Connect to backend events self.pubpen.subscribe('user.info', self.handle_user_info) self.pubpen.subscribe('user.login_success', self.handle_login) self.pubpen.subscribe('ship.moved', self.handle_ship_moved) # # Widget methods #
def __init__(self, title, message, entry_prompt=None, entry_text='', buttons=[], ring=None): button_widgets = [] for button in buttons: button_widgets.append(('pack', button)) button_columns = urwid.Columns(button_widgets, dividechars=2) rows = [] rows.append(urwid.Text(message)) if entry_prompt: self.entry = MyEdit(entry_prompt, edit_text=entry_text, ring=ring) rows.append(self.entry) else: self.entry = None rows.append(urwid.Divider()) rows.append(button_columns) listbox = urwid.ListBox(rows) super(ButtonDialog, self).__init__(urwid.LineBox(listbox, title))
def __init__(self, app, title, prompt, button, text, ring=None): self.app = app save_button = FixedButton(button) cancel_button = FixedButton('Cancel') urwid.connect_signal(save_button, 'click', lambda button:self._emit('save')) urwid.connect_signal(cancel_button, 'click', lambda button:self._emit('cancel')) button_widgets = [('pack', save_button), ('pack', cancel_button)] button_columns = urwid.Columns(button_widgets, dividechars=2) rows = [] self.entry = MyEdit(edit_text=text, multiline=True, ring=ring) rows.append(urwid.Text(prompt)) rows.append(self.entry) rows.append(urwid.Divider()) rows.append(button_columns) pile = urwid.Pile(rows) fill = urwid.Filler(pile, valign='top') super(TextEditDialog, self).__init__(urwid.LineBox(fill, title))
def __init__(self, app, board, topic, callback=None): super(BoardRow, self).__init__('', on_press=callback, user_data=(board.key, board.title)) self.app = app self.mark = False self._style = None self.board_key = board.key if topic: self.topic_key = topic.key self.indent = ' ' else: self.topic_key = None self.indent = '' self.board_title = board.title self.title = mywid.SearchableText('') self._setTitle(board.title, self.indent) self.title.set_wrap_mode('clip') self.active_stories = urwid.Text(u'', align=urwid.RIGHT) col = urwid.Columns([ self.title, ('fixed', ACTIVE_COL_WIDTH, self.active_stories), ]) self.row_style = urwid.AttrMap(col, '') self._w = urwid.AttrMap(self.row_style, None, focus_map=self.board_focus_map) self.update(board)
def __init__(self, title, topics): button_widgets = [] ok_button = mywid.FixedButton('OK') cancel_button = mywid.FixedButton('Cancel') urwid.connect_signal(ok_button, 'click', lambda button:self._emit('ok')) urwid.connect_signal(cancel_button, 'click', lambda button:self._emit('cancel')) button_widgets.append(('pack', ok_button)) button_widgets.append(('pack', cancel_button)) button_columns = urwid.Columns(button_widgets, dividechars=2) self.topic_buttons = [] self.topic_keys = {} rows = [] for key, name in topics: button = mywid.FixedRadioButton(self.topic_buttons, name) self.topic_keys[button] = key rows.append(button) rows.append(urwid.Divider()) rows.append(button_columns) pile = urwid.Pile(rows) fill = urwid.Filler(pile, valign='top') super(TopicSelectDialog, self).__init__(urwid.LineBox(fill, title))
def __init__(self, app, project, topic, callback=None): super(ProjectRow, self).__init__('', on_press=callback, user_data=(project.key, project.name)) self.app = app self.mark = False self._style = None self.project_key = project.key if topic: self.topic_key = topic.key self.indent = ' ' else: self.topic_key = None self.indent = '' self.project_name = project.name self.name = mywid.SearchableText('') self._setName(project.name, self.indent) self.name.set_wrap_mode('clip') self.active_stories = urwid.Text(u'', align=urwid.RIGHT) col = urwid.Columns([ self.name, ('fixed', ACTIVE_COL_WIDTH, self.active_stories), ]) self.row_style = urwid.AttrMap(col, '') self._w = urwid.AttrMap(self.row_style, None, focus_map=self.project_focus_map) self.update(project)
def __init__(self, topic, callback=None): super(TopicRow, self).__init__('', on_press=callback, user_data=(topic.key, topic.name)) self.mark = False self._style = None self.topic_key = topic.key self.name = urwid.Text('') self._setName(topic.name) self.name.set_wrap_mode('clip') self.active_stories = urwid.Text(u'', align=urwid.RIGHT) col = urwid.Columns([ self.name, ('fixed', ACTIVE_COL_WIDTH, self.active_stories), ]) self.row_style = urwid.AttrMap(col, '') self._w = urwid.AttrMap(self.row_style, None, focus_map=self.project_focus_map) self._style = 'subscribed-project' self.row_style.set_attr_map({None: self._style}) self.update(topic)
def __init__(self, app, story, enabled_columns, callback=None): super(StoryRow, self).__init__('', on_press=callback, user_data=story.key) self.app = app self.story_key = story.key self.enabled_columns = enabled_columns self.title = mywid.SearchableText(u'', wrap='clip') self.id = mywid.SearchableText(u'') self.updated = mywid.SearchableText(u'') self.status = mywid.SearchableText(u'') self.creator = mywid.SearchableText(u'', wrap='clip') self.mark = False self.columns = urwid.Columns([], dividechars=1) self.row_style = urwid.AttrMap(self.columns, '') self._w = urwid.AttrMap(self.row_style, None, focus_map=self.story_focus_map) self.update(story)
def open_confirm_prompt(self, callback, title="", content="", yestxt="Yes", notxt="No", align="center"): def create_cb(bool): def res(*k, **a): callback(bool) self.close_pop_up() return res self.open_pop_up( urwid.Filler(urwid.Text(content, align=align)), header=urwid.Text( title, align='center'), footer=urwid.Columns([ (urwid.Button(yestxt, create_cb(True))), (urwid.Button(notxt, create_cb(False))), ]), height=6, width=50) self.pop_up.set_focus("footer") logger.debug("Confirm prompt text: " + str(content))
def __init__(self, *widgets, cls=urwid.Columns, **kwargs): """Create new Group widget Widgets can be added by providing mappings as positional arguments. Each mapping is then provided to the `add` method as keyword arguments. cls: `Columns` or `Pile` (or derivatives of either) All other keyword arguments are forwarded to `cls` on instantiation. """ self._cls = cls self._main = cls([], **kwargs) self._items_list = [] self._items_dict = {} # Add initial widgets for widget in widgets: self.add(**widget) super().__init__(self._main)
def __init__(self, num_cores, max_mem): self.cpu_utilbar = urwid.ProgressBar('resource_bar_empty', 'resource_bar', done=num_cores) self.mem_utilbar = urwid.ProgressBar('resource_bar_empty', 'resource_bar', done=max_mem) super(ResourceMonitor, self).__init__(urwid.Pile([ urwid.Columns([ urwid.Text("CPU Util", align="right"), self.cpu_utilbar, urwid.Divider(), urwid.Text("Memory Capacity", align="right"), self.mem_utilbar ]), # urwid.Columns([ # urwid.Text("CPU Sched Latency"), # urwid.ProgressBar('resource_bar_empty', 'resource_bar'), # urwid.Divider(), # urwid.Text("Memory Paging"), # urwid.ProgressBar('resource_bar_empty', 'resource_bar'), # ]) ]))
def docfield(self, field): attr_map = field return urwid.Columns( [ ( 'fixed', self.c1width, urwid.AttrMap( urwid.Text(field + ':'), 'field', 'field_focus' ) ), urwid.AttrMap( self.fields[field], attr_map ) ] )
def __init__(self, text, height, width, constr, items, has_default): j = [] if has_default: k, tail = 3, () else: k, tail = 2, ("no",) while items: j.append( items[:k] + tail ) items = items[k:] l = [] self.items = [] for tag, item, default in j: w = constr( tag, default=="on" ) self.items.append(w) w = urwid.Columns( [('fixed', 12, w), urwid.Text(item)], 2 ) w = urwid.AttrWrap(w, 'selectable','focus') l.append(w) lb = urwid.ListBox(l) lb = urwid.AttrWrap( lb, "selectable" ) DialogDisplay.__init__(self, text, height, width, lb ) self.frame.set_focus('body')
def test_focus_path(self): # big tree of containers t = urwid.Text(u'x') e = urwid.Edit(u'?') c = urwid.Columns([t, e, t, t]) p = urwid.Pile([t, t, c, t]) a = urwid.AttrMap(p, 'gets ignored') s = urwid.SolidFill(u'/') o = urwid.Overlay(e, s, 'center', 'pack', 'middle', 'pack') lb = urwid.ListBox(urwid.SimpleFocusListWalker([t, a, o, t])) lb.focus_position = 1 g = urwid.GridFlow([t, t, t, t, e, t], 10, 0, 0, 'left') g.focus_position = 4 f = urwid.Frame(lb, header=t, footer=g) self.assertEqual(f.get_focus_path(), ['body', 1, 2, 1]) f.set_focus_path(['footer']) # same as f.focus_position = 'footer' self.assertEqual(f.get_focus_path(), ['footer', 4]) f.set_focus_path(['body', 1, 2, 2]) self.assertEqual(f.get_focus_path(), ['body', 1, 2, 2]) self.assertRaises(IndexError, lambda: f.set_focus_path([0, 1, 2])) self.assertRaises(IndexError, lambda: f.set_focus_path(['body', 2, 2])) f.set_focus_path(['body', 2]) # focus the overlay self.assertEqual(f.get_focus_path(), ['body', 2, 1])
def make_failed_view(self): blank = urwid.Divider() status_header = urwid.AttrWrap(urwid.Text('Run Code Status: '), 'body') status = urwid.AttrWrap(urwid.Text('Wrong Answer'), 'hometag') columns = urwid.Columns([(17, status_header), (20, status)]) result_header = urwid.Text('--- Run Code Result: ---', align='center') passed_header = urwid.Text('Passed test cases:') s = self.result['compare_result'] passed = urwid.Text('%d/%d' % (s.count('1'), len(s))) your_input_header = urwid.Text('Your input:') your_input = urwid.Text(self.result['input']) your_answer_header = urwid.Text('Your answer:') your_answer = urwid.Text(self.result['code_output']) expected_answer_header = urwid.Text('Expected answer:') expected_answer = urwid.Text(self.result['expected_output']) list_items = [ result_header, blank, columns, blank, passed_header, passed, 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)
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)
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)
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), 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)
def __init__(self, data, header): title = [ (4, urwid.AttrWrap(urwid.Text('#'), 'body', 'focus')), (2, urwid.AttrWrap(urwid.Text(''), 'body', 'focus')), (10, urwid.AttrWrap(urwid.Text('Tag'), 'body', 'focus')), urwid.AttrWrap(urwid.Text('Title'), 'body', 'focus'), (15, urwid.AttrWrap(urwid.Text('Acceptance'), 'body', 'focus')), (15, urwid.AttrWrap(urwid.Text('Difficulty'), 'body', 'focus')), ] title_column = urwid.Columns(title) self.marks = load_marks() items = make_itemwidgets(data, self.marks) self.listbox = urwid.ListBox(urwid.SimpleListWalker(items)) header_pile = urwid.Pile([header, title_column]) urwid.Frame.__init__(self, urwid.AttrWrap(self.listbox, 'body'), header=header_pile) self.last_sort = {'attr': 'id', 'reverse': True} self.last_search_text = None
def set_y_label(self, y_label): if len(y_label) == 0: return str_y_label = [str(i) for i in y_label] y_label_nums = str_y_label[1:] y_list_walker = [(1, urwid.ListBox([urwid.Text(str_y_label[0])]))] for num in y_label_nums: y_list_walker = [urwid.ListBox([urwid.Text(num)])] + y_list_walker y_list_walker = urwid.Pile(y_list_walker, focus_item=0) y_scale_len = len(max(str_y_label, key=len)) y_notation = [('fixed', y_scale_len, y_list_walker), ('weight', 1, self.bar_graph)] self.y_label.original_widget = urwid.Columns(y_notation, dividechars=1)
def __init__(self, return_fn): self.return_fn = return_fn self.about_message = ABOUT_MESSAGE self.time_out_ctrl = urwid.Text(self.about_message) cancel_button = urwid.Button('Exit', on_press=self.on_cancel) cancel_button._label.align = 'center' if_buttons = urwid.Columns([cancel_button]) title = urwid.Text(('bold text', u" About Menu \n"), 'center') self.titles = [title, self.time_out_ctrl, if_buttons] self.main_window = urwid.LineBox(ViListBox(self.titles))
def __init__(self, label, on_press=None, user_data=None, align='right'): super(TextButton, self).__init__( label, on_press=on_press, user_data=user_data) self._label.align = align cols = urwid.Columns([self._label]) super(urwid.Button, self).__init__(cols)
def __init__(self, pic, text): content = self.get_content(text) lbox = urwid.LineBox(urwid.Pile([DIV, urwid.Padding( urwid.Columns([(8, pic), content], 4), left=3, right=3), DIV])) self.__super.__init__(urwid.AttrMap(urwid.Pile( [lbox]), 'image button', 'image button focus'))
def __init__(self, label="", label_width=15, next_callback=False): self.label, self.next_callback = label, next_callback self.edit = urwid.Padding(urwid.Edit(), left=1, right=1) label = urwid.LineBox( urwid.Text(label), tlcorner=' ', tline=' ', lline=' ', trcorner=' ', blcorner=' ', rline=' ', brcorner=' ', bline=' ') lbox = urwid.AttrMap( urwid.LineBox( self.edit, tlcorner=' ', tline=' ', lline=' ', trcorner=' ', blcorner=' ', rline=' ', brcorner=' '), 'input', 'input focus') cols = urwid.Columns([(label_width, label), lbox]) urwid.WidgetWrap.__init__(self, cols)
def __init__(self): self.walker = urwid.SimpleFocusListWalker(contents=self.log_messages) self.list_box = urwid.ListBox(self.walker) self.graph = urwid.BarGraph( attlist=['graph bg background', 'graph bg 1', 'graph bg 2'], satt={ (1, 0): 'graph bg 1 smooth', (2, 0): 'graph bg 2 smooth' } ) self.graph_widget = urwid.LineBox(self.graph, title=self.graph_title) self.default_widget = urwid.Columns([ urwid.LineBox( self.list_box, title="Logger" ), self.graph_widget ]) self.logger_widget = urwid.LineBox( self.list_box, title="Logger" )
def print_thread(self, button, thread): thr_no = self.board.thread_exists(int(thread)) thr_body = self.board.get_index()[thr_no] replies = ur.SimpleFocusListWalker([]) subject = ("reverse_red", thr_body[1]) if subject[1] == "": subject = (None, "") op = self.parse_post(thr_body[2]) op_info = ur.Text([("reverse_green", op["name"]), " " + op["stamp"] + " ", subject]) op_btn = CleanButton( "No. " + op["id"], self.reply_box, op["id"]) op_widget = ur.AttrMap(ur.Columns( [("pack", op_info), ("pack", op_btn)], 1), "reverse") replies.extend([op_widget, op["text"], self.parent.div]) if len(thr_body) > 3: for postno in range(3, len(thr_body)): reply = self.parse_post(thr_body[postno]) reply_info = ur.Text( [("green", reply["name"]), " " + reply["stamp"]]) reply_btn = CleanButton( "No. " + reply["id"], self.reply_box, reply["id"]) reply_widget = ur.Columns( [("pack", reply_info), ("pack", reply_btn)], 1) replies.extend([reply_widget, reply["text"], self.parent.div]) contents = ur.ListBox(replies) contents.set_focus(0) self.loop.Widget = ur.Frame( contents, self.parent.header, self.parent.footer, "body")
def add(self): self.numbers.append(urwid.Text(str(len(self.numbers)+1) + '| ', align='right')) if len(str(len(self.numbers)-1)) > self.width: self.width += 1 new_col = urwid.Columns([(self.width+2, self.display.line_nums), self.display.listbox], focus_column=1) self.display.top.contents['body'] = (new_col, None) # this method simply deletes a line from the end of the line numbers # note: we have to check that we didnt delete the last line or we get an index out of bounds!
def redraw_tabs(self): # this is done to ensure that the bottom bar is re-drawn after opening files foot_col = urwid.Columns(self.display.tabs) foot = urwid.AttrMap(foot_col, 'footer') if self.display.layout: self.display.top.contents['header'] = (foot, None) else: self.display.top.contents['footer'] = (foot, None)
def toggle_line_numbers(self): self.show_lnums = not self.show_lnums if self.show_lnums: self.line_nums.populate(self.listbox.lines) self.body_col = urwid.Columns([(self.line_nums.width+2, self.line_nums), self.listbox], focus_column=1) else: self.body_col.contents.pop(0) self.top.contents['body'] = (self.body_col, None) self.update_line_numbers()
def __init__(self, pubpen): self.pubpen = pubpen username_label = urwid.Text('Username: ', align='right') password_label = urwid.Text('Password: ', align='right') self.username = urwid.Edit() self.password = urwid.Edit() login_button = urwid.Button('Login') decorated_login_button = urwid.AttrMap(login_button, None, focus_map='reversed') quit_button = urwid.Button('Quit') decorated_quit_button = urwid.AttrMap(quit_button, None, focus_map='reversed') buttons = urwid.Columns(( (len('Login') + 4, decorated_login_button), (len('Quit') + 4, decorated_quit_button), ), focus_column=1) labels = urwid.Pile([username_label, password_label]) self.fields = urwid.Pile([self.username, self.password, buttons], focus_item=0) entry_box = urwid.Columns([labels, self.fields]) self.status_message = urwid.Text(' ', align='center') entry_with_status = urwid.Pile([entry_box, self.status_message]) padded_entry_with_status = urwid.Padding(entry_with_status, align='center') self.display = urwid.Filler(padded_entry_with_status, valign='middle') decorate = urwid.LineBox(self.display) super().__init__(decorate) self.focusable_widgets = (w for w in itertools.cycle(( ((self.fields, 1),), ((self.fields, 2), (buttons, 0)), ((self.fields, 2), (buttons, 1)), ((self.fields, 0),) ))) urwid.connect_signal(login_button, 'click', self.attempt_login) urwid.connect_signal(quit_button, 'click', self.quit) self.pubpen.subscribe('user.login_success', self.handle_login_success) self.pubpen.subscribe('user.login_failure', self.handle_login_failure)
def __init__(self, pubpen): self.pubpen = pubpen # # Always displayed widgets # self.menu_bar_window = MenuBarWindow(self.pubpen) self.info_window = InfoWindow(self.pubpen) self.main_window = MainWindow(self.pubpen) self.msg_window = MessageWindow(self.pubpen) pile = urwid.Pile((self.main_window, (self.msg_window.height, self.msg_window), )) cols = urwid.Columns((pile, (15, self.info_window))) layout = urwid.Pile(( ('pack', self.menu_bar_window), ('weight', 1, cols), )) self.top = urwid.Frame(layout) super().__init__(self.top) tline = self.tline_widget[0] self.status_bar = StatusBar(self.pubpen, spacer=tline.div_char) self.tline_widget.contents.clear() self.tline_widget.contents.extend(( (tline, self.tline_widget.options('given', 1, False)), (self.status_bar, self.tline_widget.options('weight', 1, False)), (tline, self.tline_widget.options('given', 1, False)), ))
def __init__(self, app): super(StatusHeader, self).__init__(urwid.Columns([])) self.app = app self.title_widget = urwid.Text(u'Start') self.error_widget = urwid.Text('') self.offline_widget = urwid.Text('') self.sync_widget = urwid.Text(u'Sync: 0') self.held_widget = urwid.Text(u'') self._w.contents.append((self.title_widget, ('pack', None, False))) self._w.contents.append((urwid.Text(u''), ('weight', 1, False))) self._w.contents.append((self.held_widget, ('pack', None, False))) self._w.contents.append((self.error_widget, ('pack', None, False))) self._w.contents.append((self.offline_widget, ('pack', None, False))) self._w.contents.append((self.sync_widget, ('pack', None, False))) self.error = None self.offline = None self.title = None self.message = None self.sync = None self.held = None self._error = False self._offline = False self._title = '' self._message = '' self._sync = 0 self._held = 0 self.held_key = self.app.config.keymap.formatKeys(keymap.LIST_HELD)
def __init__(self): self.prefix_text = urwid.Text(u' \N{WATCH} ') self.breadcrumbs = urwid.Columns([], dividechars=3) self.display_widget = urwid.Columns( [('pack', self.prefix_text), self.breadcrumbs]) super(BreadCrumbBar, self).__init__(self.display_widget)
def __init__(self, headers=[], columns=None): if columns is None: cols = [('pack', TableColumn([('pack', w)])) for w in headers] else: cols = [('pack', TableColumn([])) for x in range(columns)] super(Table, self).__init__( urwid.Columns(cols))
def __init__(self): cols = [urwid.Text(u' Board'), (ACTIVE_COL_WIDTH, urwid.Text(u'Active'))] super(BoardListHeader, self).__init__(urwid.Columns(cols))
def __init__(self, app, project_key): self.app = app save_button = mywid.FixedButton(u'Save') cancel_button = mywid.FixedButton(u'Cancel') urwid.connect_signal(save_button, 'click', lambda button:self._emit('save')) urwid.connect_signal(cancel_button, 'click', lambda button:self._emit('cancel')) rows = [] buttons = [('pack', save_button), ('pack', cancel_button)] buttons = urwid.Columns(buttons, dividechars=2) if project_key: with self.app.db.getSession() as session: project = session.getProject(project_key) project_name = project.name else: project_name = None self.project_button = ProjectButton(self.app, project_key, project_name) self.title_field = mywid.MyEdit(u'', edit_text=u'', ring=app.ring) self.description_field = mywid.MyEdit(u'', edit_text='', multiline=True, ring=app.ring) for (label, w) in [ (u'Title:', self.title_field), (u'Description:', self.description_field), (u'Project:', ('pack', self.project_button)), ]: row = urwid.Columns([(12, urwid.Text(label)), w]) rows.append(row) rows.append(urwid.Divider()) rows.append(buttons) pile = urwid.Pile(rows) fill = urwid.Filler(pile, valign='top') super(NewStoryDialog, self).__init__(urwid.LineBox(fill, 'New Story'))
def __init__(self, app): self.app = app save_button = mywid.FixedButton(u'Save') cancel_button = mywid.FixedButton(u'Cancel') urwid.connect_signal(save_button, 'click', lambda button:self._emit('save')) urwid.connect_signal(cancel_button, 'click', lambda button:self._emit('cancel')) rows = [] buttons = [('pack', save_button), ('pack', cancel_button)] buttons = urwid.Columns(buttons, dividechars=2) self.project_button = ProjectButton(self.app) self.status_button = StatusButton(self.app) self.assignee_button = AssigneeButton(self.app) self.title_field = mywid.MyEdit(u'', edit_text=u'', ring=app.ring) for (label, w) in [ (u'Project:', ('pack', self.project_button)), (u'Title:', self.title_field), (u'Status:', ('pack', self.status_button)), (u'Assignee:', ('pack', self.assignee_button)), ]: row = urwid.Columns([(12, urwid.Text(label)), w]) rows.append(row) rows.append(urwid.Divider()) rows.append(buttons) pile = urwid.Pile(rows) fill = urwid.Filler(pile, valign='top') super(NewTaskDialog, self).__init__(urwid.LineBox(fill, 'New Task'))
def __init__(self, app, board_key): super(BoardView, self).__init__(urwid.Pile([])) self.log = logging.getLogger('boartty.view.board') self.searchInit() self.app = app self.board_key = board_key self.worklist_keys = set() self.title_label = urwid.Text(u'', wrap='clip') self.description_label = urwid.Text(u'') board_info = [] board_info_map={'story-data': 'focused-story-data'} for l, v in [("Title", self.title_label), ("Description", self.description_label), ]: row = urwid.Columns([(12, urwid.Text(('story-header', l), wrap='clip')), v]) board_info.append(row) board_info = urwid.Pile(board_info) self.listbox = urwid.ListBox(urwid.SimpleFocusListWalker([])) self._w.contents.append((self.app.header, ('pack', 1))) self._w.contents.append((urwid.Divider(), ('pack', 1))) self._w.contents.append((self.listbox, ('weight', 1))) self._w.set_focus(2) self.listbox.body.append(board_info) self.listbox.body.append(urwid.Divider()) self.listbox_board_start = len(self.listbox.body) lane_columns = urwid.Columns([], dividechars=1) self.listbox.body.append(lane_columns) self.lane_manager = mywid.ListUpdateManager(lane_columns) self.refresh() self.listbox.set_focus(1)
def show_channel_selector(self): self.pile.contents = [ (self.w_lb, self.pile.options()), (urwid.Columns( [('pack', self.w_text), ('weight', 1, self.w_typing)]), self.pile.options()), (self.chat_widget.w_channel_cols, self.pile.options()) ] self.pile.focus_position = 2
def hide_channel_selector(self): self.pile.contents = [ (self.w_lb, self.pile.options()), (urwid.Columns( [('pack', self.w_text), ('weight', 1, self.w_typing)]), self.pile.options()), ] self.pile.focus_position = 0
def __init__(self, chat_widget): self.chat_widget = chat_widget self.w_cols = urwid.Columns([]) self._selectable = True self.update_columns() self.__super.__init__(self.w_cols)
def __init__(self, ui): self.ui = ui self.w_cols = urwid.Columns([]) self._selectable = True self.update_columns() self.__super.__init__(self.w_cols)