本文整理汇总了Python中urwid.Pile.render方法的典型用法代码示例。如果您正苦于以下问题:Python Pile.render方法的具体用法?Python Pile.render怎么用?Python Pile.render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urwid.Pile
的用法示例。
在下文中一共展示了Pile.render方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exploreFieldSet
# 需要导入模块: from urwid import Pile [as 别名]
# 或者: from urwid.Pile import render [as 别名]
def exploreFieldSet(field_set, args, options={}):
charset = getTerminalCharset()
ui = urwid.curses_display.Screen()
ui.register_palette((
('focus', 'white', 'dark blue'),
('sep', 'white', 'dark red'),
('input', 'black', 'light gray'),
))
msgs = [[],[],0]
hachoir_log.use_print = False
def logger(level, prefix, text, ctxt):
if ctxt is not None:
c = []
if hasattr(ctxt, "_logger"):
c[:0] = [ ctxt._logger() ]
if issubclass(ctxt.__class__, Field):
ctxt = ctxt["/"]
name = logger.objects.get(ctxt)
if name:
c[:0] = [ name ]
if c:
text = "[%s] %s" % ('|'.join(c), text)
if not isinstance(text, unicode):
text = unicode(text, charset)
msgs[0].append((level, prefix, text))
logger.objects = WeakKeyDictionary()
hachoir_log.on_new_message = logger
preload_fields = 1 + max(0, args.preload)
log_count = [ 0, 0, 0 ]
sep = Separator("log: %%u/%%u/%%u | %s " % _("F1: help"))
sep.set_info(*tuple(log_count))
body = Tabbed(sep)
help = ('help', ListBox([ Text(getHelpMessage()) ]))
logger.objects[field_set] = logger.objects[field_set.stream] = name = u'root'
body.append((name, TreeBox(charset, Node(field_set, None), preload_fields, args.path, options)))
log = BoxAdapter(ListBox(msgs[1]), 0)
log.selectable = lambda: False
wrapped_sep = AttrWrap(sep, 'sep')
footer = Pile([ ('flow', wrapped_sep), log ])
# awful way to allow the user to hide the log widget
log.render = lambda size, focus=False: BoxAdapter.render(log, size[:1], focus)
footer.render = lambda (maxcol,), focus=False: Pile.render(footer, (maxcol, sep.rows((maxcol,))+log.height), focus)
top = Frame(body, None, footer)
def input_enter(w):
footer.widget_list[0] = w
footer.set_focus(0)
top.set_focus('footer')
def input_leave():
footer.widget_list[0] = wrapped_sep
footer.set_focus(0)
top.set_focus('body')
input = Input(input_enter, input_leave)
def run():
msg = _resize = retry = 0
events = ( "window resize", )
profile_display = args.profile_display
while True:
for e in events:
try:
if e == "window resize":
size = ui.get_cols_rows()
resize = log.height
else:
e = top.keypress(size, e)
if e is None:
pass
elif e in ('f1', '?'):
try:
body.select(body.tabs.index(help))
except ValueError:
body.append(help)
resize = log.height
elif e in ('esc', 'ctrl w'):
body.close()
if body.box_widget is None:
return
resize = log.height
elif e == '+':
if log.height:
resize = log.height - 1
elif e == '-':
resize = log.height + 1
elif e == 'q':
return
#except AssertionError:
# hachoir_log.error(getBacktrace())
except NewTab_Stream, e:
stream = e.field.getSubIStream()
logger.objects[stream] = e = "%u/%s" % (body.active, e.field.absolute_address)
parser = guessParser(stream)
if not parser:
#.........这里部分代码省略.........