本文整理汇总了Python中urwid.Frame方法的典型用法代码示例。如果您正苦于以下问题:Python urwid.Frame方法的具体用法?Python urwid.Frame怎么用?Python urwid.Frame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urwid
的用法示例。
在下文中一共展示了urwid.Frame方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Frame [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: build
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Frame [as 别名]
def build(self):
# buttons
done = urwid.Button("Done")
urwid.connect_signal(done, 'click', self._done_multiselect)
done = urwid.AttrWrap(done, 'selectable', 'butfocus')
add = urwid.Button("Add New")
urwid.connect_signal(add, 'click', self._add_new)
add = urwid.AttrWrap(add, 'selectable', 'butfocus')
cancel = urwid.Button("Cancel")
urwid.connect_signal(cancel, 'click', self._cancel)
cancel = urwid.AttrWrap(cancel, 'selectable', 'butfocus')
# footer and header
header = urwid.GridFlow([done, add, cancel], 15, 3, 1, 'center')
footer = urwid.Padding(urwid.Text(
("popup", "Tab to button box to select buttons. Arrow keys transfer selection.")))
body = self._build_body()
return urwid.Frame(body, header=header, footer=footer, focus_part="body")
示例3: __init__
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Frame [as 别名]
def __init__(self, session, debug=False):
self.loop =None
self.session = session
self.footer = urwid.AttrMap(
urwid.Text([
("key", "ESC"), " Quit ",
("key", "Tab"), " Move Selection ",
("key", "F1"), " Help ",
("key", "F2"), " Reset ",
("key", "F5"), " Add Test Case ",
("key", "F6"), " Add Test Suite ",
("key", "F9"), " Add Equipment ",
("key", "F10"), " Add Environment ",
]),
"foot")
self.reset()
self.top = urwid.Frame(urwid.AttrMap(self.form, 'body'), footer=self.footer)
if debug:
from pycopia import logwindow
widgets.DEBUG = logwindow.DebugLogWindow()
示例4: __init__
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Frame [as 别名]
def __init__(self, name, status=None, timezone=None, phone=None, email=None, skype=None):
line = urwid.Divider('─')
header = urwid.Pile([
line,
urwid.Text([' ', name]),
line
])
contents = []
if status:
contents.append(self.format_row('status', status))
if timezone:
contents.append(self.format_row('timezone', timezone))
if phone:
contents.append(self.format_row('phone', phone))
if email:
contents.append(self.format_row('email', email))
if skype:
contents.append(self.format_row('skype', skype))
self.pile = urwid.Pile(contents)
body = urwid.Frame(urwid.Filler(self.pile, valign='top'), header, line)
super(ProfileSideBar, self).__init__(body, 'profile')
示例5: setup_widgets
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Frame [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: __init__
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Frame [as 别名]
def __init__(self, data, header):
title = [
(4, urwid.AttrWrap(urwid.Text('#'), 'body', 'focus')),
(2, urwid.AttrWrap(urwid.Text(''), 'body', 'focus')),
(10, urwid.AttrWrap(urwid.Text('Tag'), 'body', 'focus')),
urwid.AttrWrap(urwid.Text('Title'), 'body', 'focus'),
(15, urwid.AttrWrap(urwid.Text('Acceptance'), 'body', 'focus')),
(15, urwid.AttrWrap(urwid.Text('Difficulty'), 'body', 'focus')),
]
title_column = urwid.Columns(title)
self.marks = load_marks()
items = make_itemwidgets(data, self.marks)
self.listbox = urwid.ListBox(urwid.SimpleListWalker(items))
header_pile = urwid.Pile([header, title_column])
urwid.Frame.__init__(self, urwid.AttrWrap(self.listbox, 'body'), header=header_pile)
self.last_sort = {'attr': 'id', 'reverse': True}
self.last_search_text = None
示例7: keypress
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Frame [as 别名]
def keypress(self, size, key):
key = vim_key_map(key)
ignore_key = ('h', 'left')
if key in ignore_key:
pass
elif key == '1':
self.sort_list('id')
elif key == '2':
self.sort_list('title')
elif key == '3':
self.sort_list('acceptance')
elif key == '4':
self.sort_list('difficulty', conversion=self.difficulty_conversion)
elif key == 'home':
self.listbox.focus_position = 0
elif key == 'end':
self.listbox.focus_position = len(self.listbox.body) - 1
elif key == 'n':
self.handle_search(self.last_search_text, True)
else:
return urwid.Frame.keypress(self, size, key)
示例8: buildAddHeaderView
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Frame [as 别名]
def buildAddHeaderView(self, focusView):
try:
headerStringLeft = urwid.AttrWrap(urwid.Text(focusView.frame.headerString), 'header')
except:
headerStringLeft = urwid.AttrWrap(urwid.Text(''), 'header')
if len(self.watched) > 0:
headerStringRight = urwid.AttrWrap(urwid.Text(str(self.totalNewPosts) + ' new posts in ' + str(len(self.watched)) + ' watched thread(s)', 'right'), 'header')
else:
headerStringRight = urwid.AttrWrap(urwid.Text(''), 'header')
builtUrwidSplits = buildUrwidFromSplits(self.splitTuple)
log.debug(type(builtUrwidSplits))
self.body = urwid.Frame(urwid.AttrWrap(builtUrwidSplits, 'body'))
headerWidget = urwid.Columns([headerStringLeft, headerStringRight])
self.body.header = headerWidget
示例9: __init__
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Frame [as 别名]
def __init__(self, client):
self.client = client
self.screen = urwid.raw_display.Screen()
# self.screen = self.DummyScreen()
self.frame = urwid.Frame(
client.default_view,
footer=urwid.Text("", align='center'),
)
self.client.frame = self.frame
self.urwid_loop = urwid.MainLoop(
self.frame,
screen=self.screen,
palette=palette,
event_loop=self.FixedAsyncLoop(loop=client.loop),
unhandled_input=client.handle_keypresses,
pop_ups=True
)
示例10: ftbtest
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Frame [as 别名]
def ftbtest(self, desc, focus_part, header_rows, footer_rows, size,
focus, top, bottom):
class FakeWidget:
def __init__(self, rows, want_focus):
self.ret_rows = rows
self.want_focus = want_focus
def rows(self, size, focus=False):
assert self.want_focus == focus
return self.ret_rows
header = footer = None
if header_rows:
header = FakeWidget(header_rows,
focus and focus_part == 'header')
if footer_rows:
footer = FakeWidget(footer_rows,
focus and focus_part == 'footer')
f = urwid.Frame(None, header, footer, focus_part)
rval = f.frame_top_bottom(size, focus)
exp = (top, bottom), (header_rows, footer_rows)
assert exp == rval, "%s expected %r but got %r"%(
desc,exp,rval)
示例11: test_focus_path
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Frame [as 别名]
def test_focus_path(self):
# big tree of containers
t = urwid.Text(u'x')
e = urwid.Edit(u'?')
c = urwid.Columns([t, e, t, t])
p = urwid.Pile([t, t, c, t])
a = urwid.AttrMap(p, 'gets ignored')
s = urwid.SolidFill(u'/')
o = urwid.Overlay(e, s, 'center', 'pack', 'middle', 'pack')
lb = urwid.ListBox(urwid.SimpleFocusListWalker([t, a, o, t]))
lb.focus_position = 1
g = urwid.GridFlow([t, t, t, t, e, t], 10, 0, 0, 'left')
g.focus_position = 4
f = urwid.Frame(lb, header=t, footer=g)
self.assertEqual(f.get_focus_path(), ['body', 1, 2, 1])
f.set_focus_path(['footer']) # same as f.focus_position = 'footer'
self.assertEqual(f.get_focus_path(), ['footer', 4])
f.set_focus_path(['body', 1, 2, 2])
self.assertEqual(f.get_focus_path(), ['body', 1, 2, 2])
self.assertRaises(IndexError, lambda: f.set_focus_path([0, 1, 2]))
self.assertRaises(IndexError, lambda: f.set_focus_path(['body', 2, 2]))
f.set_focus_path(['body', 2]) # focus the overlay
self.assertEqual(f.get_focus_path(), ['body', 2, 1])
示例12: main_window
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Frame [as 别名]
def main_window(self) -> Any:
self.left_panel = self.left_column_view()
self.center_panel = self.message_view()
self.right_panel = self.right_column_view()
if self.controller.autohide:
body = [
(View.LEFT_WIDTH, self.left_panel),
('weight', 10, self.center_panel),
(0, self.right_panel),
]
else:
body = [
(View.LEFT_WIDTH, self.left_panel),
('weight', 10, self.center_panel),
(View.RIGHT_WIDTH, self.right_panel),
]
self.body = urwid.Columns(body, focus_column=0)
# NOTE: set_focus_changed_callback is actually called before the
# focus is set, so the message is not read yet, it will be read when
# the focus is changed again either vertically or horizontally.
self.body._contents.set_focus_changed_callback(
self.model.msg_list.read_message)
div_char = '═'
title_text = " {full_name} ({email}) - {server_name} ({url}) ".format(
full_name=self.model.user_full_name,
email=self.model.user_email,
server_name=self.model.server_name,
url=self.model.server_url)
title_bar = urwid.Columns([
urwid.Divider(div_char=div_char),
(len(title_text), urwid.Text([title_text])),
urwid.Divider(div_char=div_char),
])
w = urwid.Frame(self.body, title_bar, focus_part='body',
footer=self.footer_view())
return w
示例13: __init__
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Frame [as 别名]
def __init__(self, app, controller, model, cb):
self.app = app
self.cb = cb
self.controller = controller
self.model = model
self.config = self.app.config
self.buttons_pile_selected = False
self.frame = Frame(body=self._build_widget(),
footer=self._build_footer())
self.frame.focus_position = 'footer'
self.buttons.focus_position = 1
super().__init__(self.frame)
示例14: __init__
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Frame [as 别名]
def __init__(self, app, models, cb):
self.app = app
self.cb = cb
self.controllers = models.keys()
self.models = models
self.config = self.app.config
self.buttons_pile_selected = False
self.frame = Frame(body=self._build_widget(),
footer=self._build_footer())
super().__init__(self.frame)
示例15: getFrame
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Frame [as 别名]
def getFrame(self):
urwid.AttrMap(self.getEdit(), 'input')
frame_widget = urwid.Frame(
header=self.getHeader(),
body=self.getConsole(),
footer=urwid.AttrMap(self.getEdit(), 'input'),
focus_part='footer')
return frame_widget