本文整理汇总了Python中urwid.Padding方法的典型用法代码示例。如果您正苦于以下问题:Python urwid.Padding方法的具体用法?Python urwid.Padding怎么用?Python urwid.Padding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urwid
的用法示例。
在下文中一共展示了urwid.Padding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Padding [as 别名]
def __init__(self, key=None, value=('', '')):
self.trigger = key
self.yn = value[0]
self.yn_but = MyButton([('attention', 'Use proxy: '), self.yn], self.on_change)
self.input_addr = urwid.Edit(('attention', u' \N{BULLET} Address : '), edit_text=value[1], wrap='clip')
self.input_port = urwid.IntEdit(('attention', u' \N{BULLET} Port : '), default=value[2])
self.input_port.set_wrap_mode('clip')
exit_but = urwid.Padding(urwid.Button('OKay'.center(8), self.item_callback), 'center', 12)
widgets = [self.yn_but] \
+ [urwid.AttrMap(wid, None, 'popbgs') for wid in (self.input_addr, self.input_port, exit_but)]
self.pile = urwid.Pile(widgets)
fill = urwid.LineBox(urwid.Filler(self.pile))
self.__super.__init__(urwid.AttrWrap(fill, 'popbg'))
self.chosen = value
示例2: _show_completion_box
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Padding [as 别名]
def _show_completion_box(self):
contents = self.cli_wrapper.contents
if len(contents) == 1:
completion_box = self.commandline.completion_box
opts = ('given', completion_box.height)
max_width = self.cli_wrapper.width
pos = self.commandline.get_cursor_coords((max_width,))[0]
l_margin = pos - completion_box.margin
r_margin = max_width - pos - completion_box.min_width + completion_box.margin
padding = urwid.Padding(completion_box,
min_width=completion_box.min_width,
left=l_margin,
right=r_margin)
contents.insert(0, (padding, opts))
completion_box.focus.set_attr_map({None: PaletteItem.MARKED})
self.cli_wrapper.focus_position = 1
示例3: build
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Padding [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: generate_content
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Padding [as 别名]
def generate_content(status_code):
try:
code_descriptions, num, status_code = get_yaml_dictionary(status_code)
content = code_descriptions[status_code]
pile = urwid.Pile([
urwid.Text("STATCODE: The Manual for HTTP Status Codes and Headers\n", align="center"),
urwid.Text(("title", "STATUS MESSAGE" if num else "HEADER INFO")),
urwid.Padding(
urwid.Text(''.join([str(status_code), ": " if num else ", Example= ", content["message"], '\n'])),
left=5),
urwid.Text(("title", "CATEGORY")),
urwid.Padding(urwid.Text(''.join([content["category"], '\n'])), left=5),
urwid.Text(("title", "DESCRIPTION")),
urwid.Padding(urwid.Text(''.join([content["description"], '\n'])), left=5),
urwid.Text(("title", "COPYRIGHT")),
urwid.Padding(urwid.Text(''.join([__load_file_data(num), '\n'])), left=5),
])
padding = urwid.Padding(Scrollable(pile), left=1, right=1)
return padding
except KeyError: # None is used to print "not recognized", so KeyError. Other errors have nothing to do with it
return None
示例5: __init__
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Padding [as 别名]
def __init__(self, filename):
self.header = urwid.Text(" BINCH: %s" % (filename))
self.disasmblr = Disassembler(filename)
items = self.setup_list(True)
self.disasmlist = DisassembleList(items)
start_index = self.find_index(self.disasmblr.entry)
if start_index != -1:
self.disasmlist.set_focus(start_index)
self.history = list()
self.body = urwid.Padding(self.disasmlist, 'center', 105)
self.body = urwid.Filler(self.body, ('fixed top',1), ('fixed bottom',1))
self.footer = StatusBar("HotKeys -> g: Go to a address | s: Save | d: Remove | enter: Modify | q: Quit", self)
self.view = DisassembleWindow(self,
urwid.AttrWrap(self.body, 'body'),
urwid.AttrWrap(self.header, 'head'),
self.footer)
signals.call_delay.connect(self.sig_call_delay)
示例6: start_screen
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Padding [as 别名]
def start_screen(self):
#Ovrlay top screen at start
txt1_1=urwid.Button("New playlist [Enter URL]")
urwid.connect_signal(txt1_1, 'click', self.input_screen)
txt1 = urwid.AttrMap(txt1_1,None,focus_map='reversed')
txt2_2=urwid.Button("Load saved playlist")
urwid.connect_signal(txt2_2, 'click', self.load_list_screen)
txt2 = urwid.AttrMap(txt2_2,None,focus_map='reversed')
start_list=urwid.SimpleFocusListWalker([txt1,txt2])
box=urwid.ListBox(start_list)
selection=urwid.LineBox(
box, title='', title_align='center',
tlcorner='┌', tline='─', lline='│',
trcorner='┐', blcorner='└', rline='│',
bline='─', brcorner='┘'
)
selection_with_padding=urwid.Padding(selection,left=2,right=2)
return selection_with_padding
示例7: load_list_screen
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Padding [as 别名]
def load_list_screen(self,button):
#overlay second screen after start case2
txt=urwid.Text("Choose from the following:- ")
_list=self.player_object.get_saved_lists()
saved_list=[]
for every_list in _list:
b=urwid.Button(str(every_list).rstrip(),user_data=None)
urwid.connect_signal(b, 'click', self.list_load)
saved_list.append(urwid.AttrMap(b,None,focus_map='reversed'))
box=urwid.ListBox(urwid.SimpleFocusListWalker(saved_list))
list_box=urwid.LineBox(
box, title='', title_align='center',
tlcorner='┌', tline='─', lline='│',
trcorner='┐', blcorner='└', rline='│',
bline='─', brcorner='┘'
)
list_box_padding=urwid.Padding(list_box,right=0,left=0)
self.top.original_widget=list_box_padding
示例8: make_failed_view
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Padding [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)
示例9: make_compile_error_view
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Padding [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)
示例10: make_runtime_error_view
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Padding [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)
示例11: make_unified_error_view
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Padding [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)
示例12: render_page
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Padding [as 别名]
def render_page(self):
return urwid.AttrMap(
urwid.Filler(
urwid.Pile([
urwid.Padding(
urwid.Text(self.text),
left=2, right=2),
urwid.Divider(),
urwid.Columns([
urwid.Pile([
urwid.Text("Public Network", align="center"),
urwid.Padding(self.public_buttons,left=4)
]),
urwid.Pile([
urwid.Text("Cluster Network", align="center"),
urwid.Padding(self.cluster_buttons, left=4)
])
]),
urwid.Divider(),
self.next_btn
]),
valign='top', top=1),
'active_step')
示例13: render_page
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Padding [as 别名]
def render_page(self):
host_widgets = urwid.Padding(self.host_panels,
left=2, right=2)
return urwid.AttrMap(
urwid.Filler(
urwid.Pile([
urwid.Padding(urwid.Text(self.text),
left=2, right=2),
urwid.Divider(),
host_widgets,
urwid.Divider(),
self.next_btn]),
valign='top',top=1),
'active_step')
示例14: __init__
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Padding [as 别名]
def __init__(self, chat_widget):
self.chat_widget = chat_widget
self.message = FakeMessage(datetime.datetime.min)
self._selectable = False
txt = urwid.Text(
" \n"
" \n"
" \n"
" \n"
"< moo > \n"
" ----- \n"
" \ ^__^ \n"
" \ (oo)\_______ \n"
" (__)\ )\/\ \n"
" ||----w | \n"
" || || \n"
" \n"
" \n"
"Congratulations! You have reached the top, Thats awesome! Unless "
"the channel is empty, in which case, meh... big deal.\n\n",
align=urwid.CENTER)
w = urwid.Padding(txt, left=5, right=5)
self.__super.__init__(w)
示例15: test_reduced_padding_cursor
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Padding [as 别名]
def test_reduced_padding_cursor(self):
# FIXME: This is at least consistent now, but I don't like it.
# pack() on an Edit should leave room for the cursor
# fixing this gets deep into things like Edit._shift_view_to_cursor
# though, so this might not get fixed for a while
p = urwid.Padding(urwid.Edit(u'',u''), width='pack', left=4)
self.assertEqual(p.render((10,), True).cursor, None)
self.assertEqual(p.get_cursor_coords((10,)), None)
self.assertEqual(p.render((4,), True).cursor, None)
self.assertEqual(p.get_cursor_coords((4,)), None)
p = urwid.Padding(urwid.Edit(u'',u''), width=('relative', 100), left=4)
self.assertEqual(p.render((10,), True).cursor, (4, 0))
self.assertEqual(p.get_cursor_coords((10,)), (4, 0))
self.assertEqual(p.render((4,), True).cursor, None)
self.assertEqual(p.get_cursor_coords((4,)), None)