本文整理匯總了Python中urwid.BoxAdapter方法的典型用法代碼示例。如果您正苦於以下問題:Python urwid.BoxAdapter方法的具體用法?Python urwid.BoxAdapter怎麽用?Python urwid.BoxAdapter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類urwid
的用法示例。
在下文中一共展示了urwid.BoxAdapter方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: build
# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import BoxAdapter [as 別名]
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))
示例2: build
# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import BoxAdapter [as 別名]
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")
示例3: _create_relation_input
# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import BoxAdapter [as 別名]
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)
示例4: build
# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import BoxAdapter [as 別名]
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
示例5: __init__
# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import BoxAdapter [as 別名]
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
示例6: build_widgets
# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import BoxAdapter [as 別名]
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"))
示例7: get_inner_widget
# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import BoxAdapter [as 別名]
def get_inner_widget(self):
widget = urwid.Text(('weak', '- Not Available -'), align='center')
widget = urwid.Filler(widget)
widget = urwid.BoxAdapter(widget, 3)
return widget
示例8: _process_tree
# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import BoxAdapter [as 別名]
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)))
示例9: _create_equipment_input
# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import BoxAdapter [as 別名]
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)
示例10: _create_copy_input
# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import BoxAdapter [as 別名]
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
示例11: make_frame
# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import BoxAdapter [as 別名]
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
示例12: __init__
# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import BoxAdapter [as 別名]
def __init__(self, title):
text = ["Question: ", ('title', title), "\n"]
UnicodeText.__init__(self, text)
# Must convert to BoxAdapter object if used as a flow widget.
示例13: launch_witch_readonly
# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import BoxAdapter [as 別名]
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'))
示例14: launch_witch
# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import BoxAdapter [as 別名]
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"))
示例15: show
# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import BoxAdapter [as 別名]
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