本文整理汇总了Python中urwid.SimpleListWalker方法的典型用法代码示例。如果您正苦于以下问题:Python urwid.SimpleListWalker方法的具体用法?Python urwid.SimpleListWalker怎么用?Python urwid.SimpleListWalker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urwid
的用法示例。
在下文中一共展示了urwid.SimpleListWalker方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import SimpleListWalker [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")
示例2: _create_relation_input
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import SimpleListWalker [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)
示例3: build
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import SimpleListWalker [as 别名]
def build(self):
self._showeq = urwid.Text("")
eqi = self._create_equipment_input()
maxlen = 0
uutcb = urwid.CheckBox("DUT/UUT", state=False)
urwid.connect_signal(uutcb, 'change', self._uut_select)
blist = [AM(uutcb, "important")]
for role in self._roles:
label = str(role)
maxlen = max(len(label), maxlen)
but = urwid.CheckBox(str(role), state=False)
urwid.connect_signal(but, 'change', self._multi_select, role)
blist.append(but)
roleboxes = urwid.Padding(urwid.GridFlow(blist, maxlen+4, 1, 0, "left"))
# buttons
ok, cancel = self.get_form_buttons()
buts = urwid.Columns([(10, ok), (10, cancel)], dividechars=1, focus_column=0)
return urwid.ListBox(urwid.SimpleListWalker([eqi, AM(self._showeq, "flagged"), roleboxes, buts]))
示例4: _build_list
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import SimpleListWalker [as 别名]
def _build_list(self):
choices = get_related_choices(self.session, self.modelclass, self.metadata, None)
#listbox.body.remove(listentry)
#choices.update(self.currentvalue)
wlist = []
# current = self.currentvalue
# for pk, cobj in choices.items():
# if pk in current:
# but = urwid.CheckBox(str(cobj), state=True)
# else:
# but = urwid.CheckBox(str(cobj), state=False)
# urwid.connect_signal(but, 'change', self._multi_select, (pk, cobj))
# wlist.append(but)
# return urwid.ListBox(urwid.SimpleListWalker(wlist))
示例5: setup_widgets
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import SimpleListWalker [as 别名]
def setup_widgets(self):
self.intro_frame = urwid.LineBox(
urwid.Filler(
urwid.Text(('body_text', self.INTRO_MESSAGE.format("")), align=urwid.CENTER),
valign=urwid.MIDDLE,
)
)
self.frame = urwid.Frame(
body=self.intro_frame,
footer=urwid.Text(
[self.FOOTER_START, ('heartbeat_inactive', self.HEARTBEAT_ICON)],
align=urwid.CENTER
)
)
self.loop = urwid.MainLoop(
urwid.AttrMap(self.frame, 'body_text'),
unhandled_input=show_or_exit,
palette=PALETTE,
)
self.list_walker = urwid.SimpleListWalker(self.message_list)
self.list_box = urwid.ListBox(self.list_walker)
urwid.connect_signal(self.list_walker, "modified", self.item_focused)
示例6: make_failed_view
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import SimpleListWalker [as 别名]
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)
示例7: make_compile_error_view
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import SimpleListWalker [as 别名]
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)
示例8: make_runtime_error_view
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import SimpleListWalker [as 别名]
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)
示例9: make_unified_error_view
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import SimpleListWalker [as 别名]
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)
示例10: __init__
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import SimpleListWalker [as 别名]
def __init__(self, parent):
self.text = (
"{}\n\nThe hosts are accessible to the installer. "
"The next step is to 'probe' the hosts to validate their "
"configuration is usable.".format(self.title)
)
self.probe_btn = ui_button(label='Probe', align='center',
callback=self.probe)
self.next_btn = ui_button(label='Next', align='right',
callback=self.next_page)
self.table_body = urwid.SimpleListWalker([])
self.table = urwid.ListBox(self.table_body)
self.table_footer = urwid.Text(
"Use arrow keys to move, 'space' to toggle the use of a host")
self.probed = False
UIBaseClass.__init__(self, parent)
示例11: populate_table
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import SimpleListWalker [as 别名]
def populate_table(self):
app = self.parent
table_rows = []
for hostname in sorted(app.hosts.keys()):
# establish column field defaults
if app.hosts[hostname]._facts:
this_host = app.hosts[hostname]
w = urwid.AttrMap(TableRow(this_host.info(), app),
'body',
'reverse')
table_rows.append(w)
self.table_body = urwid.SimpleListWalker(table_rows)
return
示例12: __init__
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import SimpleListWalker [as 别名]
def __init__(self, app):
self.app = app
self.walker = urwid.SimpleListWalker([])
for log_record in logger.get_logs():
self._append_log(log_record)
logger.on_log_event += self._append_log
self.listbox = urwid.ListBox(self.walker)
self.debug_data = urwid.Text('')
super(DebugPage, self).__init__([
('pack', self.debug_data),
('pack', urwid.Text('')),
('pack', urwid.Text('Hit "Enter" to copy selected message to clipboard.')),
('pack', urwid.Divider(u'\u2550')),
self.listbox
])
gp.auth_state_changed += self.update
self.update()
示例13: __init__
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import SimpleListWalker [as 别名]
def __init__(self, optimizer):
self.optimizer = optimizer
self.guidanceOptions = copy.deepcopy(optimizer.humanGuidedATPEOptimizer.guidanceOptions)
self.parameterLockedValueEdits = {}
self.parameterMinEdits = {}
self.parameterMaxEdits = {}
self.statusLabels = {}
self.listWalker = urwid.SimpleListWalker(self.generateGrid())
listbox = urwid.ListBox(self.listWalker)
close_button = urwid.Button("Close")
urwid.connect_signal(close_button, 'click',lambda button: self.close())
buttons = urwid.Filler(urwid.Columns([close_button]))
super(HumanGuidancePopup, self).__init__(makeMountedFrame(urwid.Pile([(5, buttons), listbox]), 'Apply Human Guidance'))
self.optimizer = optimizer
示例14: initAll
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import SimpleListWalker [as 别名]
def initAll(self):
self.tasksWidget = list()
self.taskWalker = urwid.SimpleListWalker(self.tasksWidget)
self.taskListbox = urwid.ListBox(self.taskWalker)
self.taskHeader = urwid.AttrWrap(urwid.Text(["Task list"], align='center'), 'taskheader')
self.taskView = urwid.Frame(urwid.AttrWrap(self.taskListbox, 'body'), header=self.taskHeader)
### Control widgets
self.blank = urwid.Divider()
self.spinningText = urwid.Text("SPINNING (is on automated task mode)", align='center')
self.spinningButton = urwid.Button("Switch spinning OFF", self.spin_switch)
self.control_content = [
self.blank,
self.spinningText,
urwid.Text("This is another content"), self.blank,self.blank,
urwid.GridFlow(
[urwid.AttrWrap(urwid.Button("Update mission", self.update_mission), 'button'),
urwid.AttrWrap(self.spinningButton, 'button'),
urwid.AttrWrap(urwid.Button("This is a button"), 'button'),
urwid.AttrWrap(urwid.Button("This is a button"), 'button'),
urwid.AttrWrap(urwid.Button("This is a button"), 'button')]
,15, 3, 1, 'center')]
self.controlListBox = urwid.ListBox(self.control_content)
self.controlHeader = urwid.AttrWrap(urwid.Text(["Controller"], align='center'), 'header')
self.controlView = urwid.Frame(urwid.AttrWrap(self.controlListBox, 'body'), header=self.controlHeader)
#view = urwid.Frame(urwid.AttrWrap(columns, 'body'), header=header)
self.columns = urwid.Columns([self.controlView, self.taskView])
示例15: _build_test_selector
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import SimpleListWalker [as 别名]
def _build_test_selector(self):
jobs = [widgets.ListEntry(job.name) for job in db.get_job_list()]
jobwalker = urwid.SimpleListWalker(jobs)
return urwid.ListBox(jobwalker)