Python urwid.BoxAdapter() Examples
The following are 23
code examples of urwid.BoxAdapter().
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: cli.py From EvilOSX with GNU General Public License v3.0 | 6 votes |
def __init__(self): self._header = urwid.Text("Command: ") self._edit_box = urwid.Edit() self._output_list = urwid.ListBox(urwid.SimpleFocusListWalker([])) self._output_layout = urwid.BoxAdapter(self._output_list, 0) # Dynamically change size. self._lock = Lock() self._prompt_mode = False self._prompt_queue = Queue() self._main_loop = None urwid.Pile.__init__(self, [ urwid.AttrWrap(self._header, "reversed"), self._output_layout, self._edit_box ]) self.focus_item = self._edit_box
Example #2
Source File: widgets.py From pycopia with Apache License 2.0 | 6 votes |
def build(self): wlist = [] addnew = urwid.Button("Add") urwid.connect_signal(addnew, 'click', self._add_new_option) addnew = urwid.AttrWrap(addnew, 'selectable', 'butfocus') wlist.append(addnew) for attrib in getattr(self.row, self.metadata.colname): # list-like attribute entry = ListEntry(urwid.Columns( [(30, urwid.Text(str(attrib.type))), urwid.Text(unicode(attrib.value).encode("utf-8"))])) entry.attrname = attrib.type.name urwid.connect_signal(entry, 'activate', self._edit_option) urwid.connect_signal(entry, 'delete', self._delete) wlist.append(entry) listbox = urwid.ListBox(urwid.SimpleFocusListWalker(wlist)) return urwid.BoxAdapter(urwid.LineBox(listbox), max(7, len(wlist)+2))
Example #3
Source File: runner.py From pycopia with Apache License 2.0 | 6 votes |
def build(self): environments = db.get_environment_names() reports = [None] + db.get_report_names() self._envsel = widgets.ListScrollSelector(environments) self._repsel = widgets.ListScrollSelector(reports) self._tclist = urwid.SimpleListWalker([]) butcols = urwid.Columns([ ("pack", urwid.Text("environment:")), AM(self._envsel, "selectable", "butfocus"), ("pack", urwid.Text("report:")), AM(self._repsel, "selectable", "butfocus"), ], dividechars=2) header = urwid.Pile([ AM(urwid.Text("Select environment, report, and set options. Use Tab to switch to environment selector. Selected:"), "subhead"), urwid.BoxAdapter(urwid.ListBox(self._tclist), 2), butcols, ]) body = self._build_test_selector(False) return urwid.Frame(body, header=header, focus_part="body")
Example #4
Source File: widgets.py From pycopia with Apache License 2.0 | 6 votes |
def _create_relation_input(self): choices = dict(models.get_choices(self.session, self.modelclass, self.metadata.colname, None)) addnew = urwid.Button("Add New") urwid.connect_signal(addnew, 'click', self._add_new_related) # Cancel canc = urwid.Button("Cancel") urwid.connect_signal(canc, 'click', self._cancel) butcol = urwid.Columns([AM(addnew, "buttn", "buttnf"), AM(canc, "buttn", "buttnf")]) wlist = [butcol] if self.metadata.nullable: entry = ListEntry(urwid.Text("None (remove)")) urwid.connect_signal(entry, 'activate', self._single_select) wlist.append(entry) for pk, cname in choices.items(): entry = ListEntry(urwid.Text(cname)) urwid.connect_signal(entry, 'activate', self._single_select, pk) wlist.append(entry) listbox = urwid.ListBox(urwid.SimpleListWalker(wlist)) return urwid.BoxAdapter(urwid.LineBox(listbox), 9)
Example #5
Source File: widgets.py From pycopia with Apache License 2.0 | 6 votes |
def build(self): wlist = [] addnew = urwid.Button("Add") urwid.connect_signal(addnew, 'click', self._add_new_attribute) addnew = urwid.AttrWrap(addnew, 'selectable', 'butfocus') wlist.append(addnew) for attrib in getattr(self.row, self.metadata.colname): # list-like attribute entry = ListEntry(urwid.Columns( [(30, urwid.Text(str(attrib.type))), urwid.Text(unicode(attrib.value).encode("utf-8"))])) entry.attrname = attrib.type.name urwid.connect_signal(entry, 'activate', self._edit_attribute) urwid.connect_signal(entry, 'delete', self._delete) wlist.append(entry) listbox = urwid.ListBox(urwid.SimpleFocusListWalker(wlist)) return urwid.BoxAdapter(urwid.LineBox(listbox), max(7, len(wlist)+2)) # edit attrib
Example #6
Source File: widgets.py From pycopia with Apache License 2.0 | 6 votes |
def build(self): addnew = urwid.Button("Add") urwid.connect_signal(addnew, 'click', self._add_new_testequipment) addnew = urwid.AttrWrap(addnew, 'selectable', 'butfocus') wlist = [addnew] for te in getattr(self.environmentrow, self.metadata.colname): # list-like attribute entry = ListEntry( urwid.Text(self._stringify_te(te))) urwid.connect_signal(entry, 'activate', self._edit_testequipment) urwid.connect_signal(entry, 'delete', self._delete_testequipment) entry.testequipment = te if te.UUT: wlist.insert(1, entry) else: wlist.append(entry) listbox = urwid.ListBox(urwid.SimpleFocusListWalker(wlist)) return urwid.BoxAdapter(urwid.LineBox(listbox), max(7, len(wlist)+2))
Example #7
Source File: tui.py From socli with BSD 3-Clause "New" or "Revised" License | 5 votes |
def make_frame(self, data): """ Returns a new frame that is formatted correctly with respect to the window's dimensions. :param data: tuple of (answers, question_title, question_desc, question_stats, question_url) :return: a new urwid.Frame object """ answers, question_title, question_desc, question_stats, question_url = data self.data = data self.question_desc = question_desc self.url = question_url self.answer_text = AnswerText(answers) self.screenHeight, screenWidth = subprocess.check_output( ['stty', 'size']).split() self.question_text = urwid.BoxAdapter(QuestionDescription(question_desc), int(max(1, (int(self.screenHeight) - 9) / 2))) answer_frame = urwid.Frame( header=urwid.Pile([ display_header, QuestionTitle(question_title), self.question_text, QuestionStats(question_stats), urwid.Divider('-') ]), body=self.answer_text, footer=urwid.Pile([ QuestionURL(question_url), UnicodeText( u'\u2191: previous answer, \u2193: next answer, o: open in browser, \u2190: back, q: quit') ]) ) return answer_frame
Example #8
Source File: demo.py From anyMesh-Python with MIT License | 5 votes |
def load_msg_frame(): global frame, entry_box, msg_list_box msg_list_box = MessageListBox() entry_box = MsgEntryListBox() frame.body = msg_list_box frame.footer = urwid.BoxAdapter(entry_box, 7) frame.focus_position = 'footer' entry_box.set_focus(0)
Example #9
Source File: host_credentials.py From ceph-ansible-copilot with GNU Lesser General Public License v2.1 | 5 votes |
def render_page(self): w = urwid.Pile([ urwid.Padding(urwid.Text(self.text), left=1, right=1), urwid.Divider(), urwid.Padding( urwid.Columns([ ("fixed", 20, self.enable_password), ("fixed", 22, self.common_password) ]), left=1), urwid.Divider(), urwid.Padding( urwid.Columns([ ("weight", 3, urwid.Pile([ self.pending_table_title, urwid.BoxAdapter( urwid.Frame(self.pending_table, header=self.pending_table_headings), 10), ])), ("weight", 1, urwid.Pile([ self.sshok_table_title, urwid.BoxAdapter( urwid.Frame(self.sshok_table, header=self.sshok_table_headings), 10), ])) ], dividechars=1), left=1), self.check_btn ]) w.focus_position = 5 # the Check button widget return urwid.AttrMap( urwid.Filler(w, valign='top', top=1), "active_step")
Example #10
Source File: host_validation.py From ceph-ansible-copilot with GNU Lesser General Public License v2.1 | 5 votes |
def render_page(self): table_headings = [(3, urwid.Text('Sel')), (4, urwid.Text('Role')), (12, urwid.Text('Hostname')), (4, urwid.Text('CPU ')), (3, urwid.Text('RAM')), (3, urwid.Text('NIC')), (3, urwid.Text('HDD')), (3, urwid.Text('SSD')), (4, urwid.Text('Size')), (8, urwid.Text('Status'))] table_header = urwid.Columns(table_headings, 1) self.table = urwid.ListBox(self.table_body) results = urwid.Padding( urwid.BoxAdapter( urwid.LineBox( urwid.Frame(self.table, header=table_header, footer=self.table_footer), title="Host Configuration"), 13), left=1, right=1) return urwid.AttrMap( urwid.Filler( urwid.Pile([ urwid.Padding(urwid.Text(self.text), left=2, right=2), self.probe_btn, urwid.Divider(), results, self.next_btn]), valign='top', top=1), 'active_step')
Example #11
Source File: deploy.py From ceph-ansible-copilot with GNU Lesser General Public License v2.1 | 5 votes |
def render_page(self): failure_lb = urwid.ListBox(self.failure_list_w) return urwid.AttrMap( urwid.Filler( urwid.Pile([ urwid.Padding(urwid.Text(self.text), left=2, right=2), self.button_row, urwid.Divider(), urwid.Padding( urwid.Pile([ urwid.Columns([ (6, urwid.Text("Task:")), self.task_info_w ]), urwid.Columns([ urwid.Text("\nProgress", align='left'), urwid.Pile([ urwid.Text('Complete', align='center'), self.success_w]), urwid.Pile([ urwid.Text("Skipped", align='center'), self.skipped_w]), urwid.Pile([ urwid.Text("Failures", align='center'), self.failed_w]), urwid.Pile([ urwid.Text("Unreachable", align='center'), self.unreachable_w]) ])]), left=2, right=2), urwid.Divider(), urwid.Padding(self.failure_title_w, left=2), urwid.Padding( urwid.BoxAdapter(failure_lb, 10), left=2)]), valign='top', top=1), 'active_step')
Example #12
Source File: gui.py From TWchat with MIT License | 5 votes |
def createRight(self): wrapedInputEdit = wrapEdit(self.inputBox) urwid.connect_signal(self.sendButton,'click',self.on_send_button_click) self.chat_name = urwid.Text("TWchat",align='center') title = urwid.AttrMap(urwid.LineBox(self.chat_name),'button') wrapedSendButton = wrapButton(self.sendButton) bottomRight = urwid.Columns([('weight',5,wrapedInputEdit),('weight',1,wrapedSendButton)],dividechars=1) topRight= urwid.BoxAdapter(self.messageListBox,screenRows-6) return urwid.Pile([title,topRight,bottomRight])
Example #13
Source File: gui.py From TWchat with MIT License | 5 votes |
def createLeft(self): wrapedChatButton = wrapButton(self.chatButton) wrapedContactButton= wrapButton(self.contactButton) urwid.connect_signal(self.chatButton,'click',self.on_chat_button_click) urwid.connect_signal(self.contactButton,'click',self.on_contact_button_click) topLeft = urwid.Columns([wrapedChatButton,wrapedContactButton],dividechars=1) bottomLeft = urwid.BoxAdapter(self.chatListBox,screenRows-3) return urwid.Pile([topLeft,bottomLeft])
Example #14
Source File: dialog.py From redial with GNU General Public License v3.0 | 5 votes |
def show(self, loop): # Header header_text = urwid.Text('Select Public SSH Key to Copy', align='center') header = urwid.AttrMap(header_text, 'dialog') cancel_btn = urwid.Button('Cancel', self.on_cancel) cancel_btn = urwid.AttrWrap(cancel_btn, 'dialog_button', 'dialog_button_focus') footer = urwid.GridFlow([cancel_btn], 12, 1, 1, 'center') list_box = urwid.BoxAdapter(SSHListBox(on_enter=self.on_copy, body=self.ssh_keys_walker), 5) body = urwid.Filler( urwid.Pile([list_box, footer]) ) # Layout layout = urwid.Frame( body=body, header=header) layout = urwid.AttrWrap(layout, 'dialog') w = DialogOverlay( on_close=lambda: self.on_close(), on_enter=self.on_copy, top_w=urwid.AttrMap(urwid.LineBox(layout), "dialog"), bottom_w=loop.widget, align='center', width=40, valign='middle', height=10 ) loop.widget = w
Example #15
Source File: screens.py From tildemush with GNU General Public License v3.0 | 5 votes |
def launch_witch(self, data): tf = NamedTemporaryFile(delete=False, mode='w') tf.write(data["code"]) tf.close() self.witch_tab.editor.original_widget = urwid.BoxAdapter( ExternalEditor(tf.name, self.ui_loop, lambda path: self.close_witch(data, path)), self.ui_loop.screen_size[1] // 2 ) self.witch_tab.prompt = self.witch_tab.editor.original_widget self.witch_tab.refresh(data, self.scope) self.switch_tab(self.tabs.get("f2"))
Example #16
Source File: screens.py From tildemush with GNU General Public License v3.0 | 5 votes |
def launch_witch_readonly(self, data): self.witch_tab.editor.original_widget = urwid.BoxAdapter( urwid.Filler(urwid.Text(data['code'])), self.ui_loop.screen_size[1] // 2) self.witch_tab.refresh(data, self.scope) self.switch_tab(self.tabs.get('f2'))
Example #17
Source File: tui.py From socli with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, title): text = ["Question: ", ('title', title), "\n"] UnicodeText.__init__(self, text) # Must convert to BoxAdapter object if used as a flow widget.
Example #18
Source File: bundle_readme_view.py From conjure-up with MIT License | 5 votes |
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"))
Example #19
Source File: widgets.py From pycopia with Apache License 2.0 | 5 votes |
def _create_copy_input(self, b): Env = models.Environment choices = self.session.query(Env.id, Env.name).filter(Env.id != self.row.id).order_by(Env.name) canc = urwid.Button("Cancel") urwid.connect_signal(canc, 'click', self._copy_cancel) butcol = urwid.Columns([AM(canc, "buttn", "buttnf")]) wlist = [butcol] for pk, cname in choices: entry = ListEntry(urwid.Text(cname)) urwid.connect_signal(entry, 'activate', self._copy_select) entry.pkey = pk wlist.append(entry) listbox = urwid.ListBox(urwid.SimpleListWalker(wlist)) box = urwid.BoxAdapter(urwid.LineBox(listbox), 9) self._w.header.base_widget.widget_list[-1] = box
Example #20
Source File: widgets.py From pycopia with Apache License 2.0 | 5 votes |
def _create_equipment_input(self): choices = self.session.query(models.Equipment).order_by("name") wlist = [] for row in choices: entry = ListEntry(urwid.Text(row.name)) urwid.connect_signal(entry, 'activate', self._eq_select, row) wlist.append(entry) listbox = urwid.ListBox(urwid.SimpleListWalker(wlist)) return urwid.BoxAdapter(urwid.LineBox(listbox), 9)
Example #21
Source File: container_info.py From sen with MIT License | 5 votes |
def _process_tree(self): top = self.docker_container.top().response logger.debug(top) if top: self.view_widgets.append(RowWidget([SelectableText("")])) self.view_widgets.append(RowWidget([SelectableText("Process Tree", maps=get_map("main_list_white"))])) self.view_widgets.append(BoxAdapter(ProcessTree(top), len(top)))
Example #22
Source File: viewer.py From profiling with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_inner_widget(self): widget = urwid.Text(('weak', '- Not Available -'), align='center') widget = urwid.Filler(widget) widget = urwid.BoxAdapter(widget, 3) return widget
Example #23
Source File: widgets.py From pycopia with Apache License 2.0 | 4 votes |
def build(self): sess = models.get_session() # self.edit = urwid.Edit("Edit me: ", multiline=True) # header = urwid.AttrMap(urwid.Text("Edit this text"), "head") # buts = self.get_form_buttons() # # fi = SimpleEdit() # ls = ListScrollSelector(["one", "two", "three", "four", "five", "six"]) # urwid.connect_signal(ls, 'click', self._scroll_select) # # cols = urwid.Columns([fi, urwid.Edit("input: ", multiline=False), ls, # (25, AM(urwid.Text("legend", align="right"), "collabel")), # AM(urwid.Edit("input", multiline=False), "body")]) # # tefrm = urwid.BoxAdapter(TestEquipmentAddForm(sess), 20) # listbox = urwid.ListBox(urwid.SimpleListWalker([self.edit, tefrm, cols, buts])) # # frm = urwid.Frame(listbox, header=header) #ovr = urwid.Frame(urwid.Filler(urwid.Text("Inside frame"))) #ovl = urwid.Overlay(urwid.LineBox(ovr), frm, "center", 80, "middle", 24) T = urwid.Text M = models.Equipment md = models.get_column_metadata(M, "interfaces") eq = sess.query(M).get(80) choices = get_related_choices(sess, M, md, None) #DEBUG(choices) current = eq.interfaces currentvalues = {} for v in current.values(): currentvalues[v.id] = v leftlist = [] rightlist = [] for pk, row in choices.items(): entry = ListEntry(urwid.Text(unicode(row).encode("utf-8"))) #urwid.connect_signal(entry, 'activate', self._single_select, pk) leftlist.append(entry) for pk, row in currentvalues.items(): entry = ListEntry(urwid.Text(unicode(row).encode("utf-8"))) #urwid.connect_signal(entry, 'activate', self._single_select, pk) rightlist.append(entry) left = urwid.ListBox(urwid.SimpleListWalker(leftlist)) right = urwid.ListBox(urwid.SimpleListWalker(rightlist)) center = urwid.Filler(urwid.Text("<-")) return urwid.Columns([left, center, right]) #return frm