本文整理汇总了Python中urwid.Frame类的典型用法代码示例。如果您正苦于以下问题:Python Frame类的具体用法?Python Frame怎么用?Python Frame使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Frame类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, loop):
header = [AttrWrap(Text(TITLE_TEXT), "border"),
AttrWrap(Text('(Q) Quit'), "border"),
AttrWrap(Text('(F5) Refresh'), "border"),
AttrWrap(Text('(F6) Add units'), "border"),
AttrWrap(Text('(F8) Console'), "border")]
header = Columns(header)
self.timer = Text("", align="left")
self.status_info = Text("", align="left")
self.horizon_url = Text("", align="right")
self.jujugui_url = Text("", align="right")
footer = Columns([('weight', 0.2, self.status_info),
('weight', 0.1, self.timer),
('weight', 0.2, self.horizon_url),
('weight', 0.2, self.jujugui_url)])
footer = AttrWrap(footer, "border")
self.poll_interval = 10
self.ticks_left = 0
self.juju_state = None
self.maas_state = None
self.nodes = ListWithHeader(NODE_HEADER)
self.loop = loop
self.cr = CommandRunner()
Frame.__init__(self, header=header, body=self.nodes,
footer=footer)
self.controller_overlay = ControllerOverlay(self, self.cr)
self._target = self.controller_overlay
示例2: __init__
def __init__(self,
configuration):
Frame.__init__(self,
WelcomeBuffer(),
header=TabsWidget(),
footer=StatusBar(''))
self._configuration = configuration
self._editor_mode = False
示例3: create_interface
def create_interface(self):
self.screen = Screen()
self.screen.start()
self.screen.register_palette([
("title", "white", "dark blue", "standout"),
("line", "light gray", "black"),
("help", "white", "dark blue")]
)
self.body = ListBox(SimpleListWalker([]))
self.lines = self.body.body
self.title = Text(MAIN_TITLE)
self.header = AttrWrap(self.title, "title")
self.help = AttrWrap(
Text(HELP_STRINGS["main"]),
"help"
)
self.input = Edit(caption="%s> " % self.ircchannel)
self.footer = Pile([self.help, self.input])
self.top = Frame(self.body, self.header, self.footer)
示例4: __init__
def __init__(self, start_date=None, end_date=None, period=None):#{{{
self.period = period
if start_date is None:
start_date = period + relativedelta(day=1)
self.start_date = start_date
if end_date is None:
end_date = period + relativedelta(day=31)
self.end_date = end_date
title = "Subdiario de ventas"
if period:
stitle = " (periodo %s)" % period.strftime("%m/%Y")
else:
stitle = " (%s - %s)" % (start_date.strftime("%d/%m/%Y"), end_date.strftime("%d/%m/%Y"))
list_header = Columns([
('fixed', 2, Divider()),
('fixed', 3, Text(u"Tip", align='center')),
('fixed', 6, Text(u"Número", align='center')),
Text(u"Razón Social", align='left'),
('fixed', 5, Text(u"Hora", align='left')),
('fixed', 3, Text(u"Ven", align='right')),
('fixed', 6, Text(u"Impues", align='right')),
('fixed', 6, Text(u"Descue", align='right')),
('fixed', 9, Text(u"Total".upper(), align='right')),
], dividechars=1)
title_row = [('listado.title.important', title), stitle]
header_row = [
AttrMap(Text(title_row, align='center', wrap='clip'), 'listado.title'),
AttrMap(list_header, 'listado.list_header'),
]
header = Pile(header_row)
footer = Text("Calculando ...")
self.short_footer = None
self.large_footer = None
self._current_footer = 0
query = session.query(Documento.fecha).filter(Documento.fecha.between(start_date, end_date))\
.order_by(Documento.fecha).distinct()
treestore = TreeListWalker([DateNode(k[0]) for k in query])
treebox = TreeListBox(treestore)
self.content = Frame(
AttrMap(treebox, 'listado.body'),
header=header,
footer=AttrMap(footer, 'listado.footer'))
self.configure_subprocess()
self.__super.__init__(self.content,
height=('relative', 100),
width=('relative', 100),
with_border=False)
示例5: keypress
def keypress(self, size, key):
""" Signal binding for NodeViewMode
Keys:
* F5 - Refreshes the node list
"""
if key == 'f5':
self.ticks_left = 0
return Frame.keypress(self, size, key)
示例6: __init__
def __init__(self):
_check_encoding() # Make sure terminal supports utf8
header = Header()
body = Banner()
footer = StatusBar('')
self.frame = Frame(body,
header=header,
footer=footer)
super().__init__(self.frame)
示例7: __init__
def __init__(self, header=None, body=None, footer=None):
_check_encoding() # Make sure terminal supports utf8
self.header = header if header else Header()
self.body = body if body else Banner()
self.footer = footer if footer else StatusBar('')
self.frame = Frame(self.body,
header=self.header,
footer=self.footer)
self.placement_view = None
super().__init__(self.frame)
示例8: __init__
def __init__(self,
configuration):
self._configuration = configuration
self._editor = None
# header
header = TabsWidget()
# body
body = Banner(configuration)
# footer
self._status_bar = configuration.styles.get('status_bar', False)
if self._status_bar:
footer = StatusBar('')
else:
footer = None
Frame.__init__(self,
body,
header=header,
footer=footer)
示例9: __init__
def __init__(self, header=None, body=None, footer=None):
self.header = header if header else Header()
self.body = body if body else Banner()
self.footer = footer if footer else StatusBarWidget()
self.frame = Frame(self.body,
header=self.header,
footer=self.footer)
self.services_view = None
self.placement_view = None
self.controller = None
self.machine_wait_view = None
self.node_install_wait_view = None
self.add_services_dialog = None
super().__init__(self.frame)
示例10: __init__
def __init__(self, header=None, body=None, footer=None):
_check_encoding() # Make sure terminal supports utf8
cb = self.show_exception_message
utils.register_async_exception_callback(cb)
self.header = header if header else Header()
self.body = body if body else Banner()
self.footer = footer if footer else StatusBar("")
self.frame = Frame(self.body, header=self.header, footer=self.footer)
self.services_view = None
self.placement_view = None
self.controller = None
self.machine_wait_view = None
self.add_services_dialog = None
super().__init__(self.frame)
示例11: __init__
def __init__(self):
self._editor = None
# header
header = TabsWidget()
# body
body = Banner()
# footer
self._status_bar = configuration.styles.get("status_bar", False)
if self._status_bar:
footer = StatusBar("")
else:
footer = None
self.frame = Frame(body, header=header, footer=footer)
super(CursesInterface, self).__init__(self.frame)
示例12: __init__
def __init__(self, configuration):
self._configuration = configuration
self._editor = None
# header
header = TabsWidget()
# body
body = Banner(configuration)
# footer
self._status_bar = configuration.styles.get("status_bar", False)
if self._status_bar:
footer = StatusBar("")
else:
footer = None
self.frame = Frame(body, header=header, footer=footer)
WidgetWrap.__init__(self, self.frame)
示例13: PegasusGUI
class PegasusGUI(WidgetWrap):
def __init__(self, header=None, body=None, footer=None):
_check_encoding() # Make sure terminal supports utf8
cb = self.show_exception_message
utils.register_async_exception_callback(cb)
self.header = header if header else Header()
self.body = body if body else Banner()
self.footer = footer if footer else StatusBar('')
self.frame = Frame(self.body,
header=self.header,
footer=self.footer)
self.services_view = None
self.placement_view = None
self.controller = None
self.machine_wait_view = None
self.add_services_dialog = None
super().__init__(self.frame)
def _build_overlay_widget(self,
top_w,
align,
width,
valign,
height,
min_width,
min_height):
return Overlay(top_w=Filler(top_w),
bottom_w=self.frame,
align=align,
width=width,
valign=valign,
height=height,
min_width=width,
min_height=height)
def show_widget_on_top(self,
widget,
width,
height,
align='center',
valign='middle',
min_height=0,
min_width=0):
"""Show `widget` on top of :attr:`frame`."""
self._w = self._build_overlay_widget(top_w=widget,
align=align,
width=width,
valign=valign,
height=height,
min_width=min_width,
min_height=min_height)
def focus_next(self):
if hasattr(self.frame.body, 'scroll_down'):
self.frame.body.scroll_down()
def focus_previous(self):
if hasattr(self.frame.body, 'scroll_up'):
self.frame.body.scroll_up()
def focus_first(self):
if hasattr(self.frame.body, 'scroll_top'):
self.frame.body.scroll_top()
def focus_last(self):
if hasattr(self.frame.body, 'scroll_bottom'):
self.frame.body.scroll_bottom()
def hide_widget_on_top(self):
"""Hide the topmost widget (if any)."""
self._w = self.frame
def show_help_info(self):
widget = HelpScreen()
self.show_widget_on_top(widget, width=80, height=22,
align="center", valign="middle",
min_height=10)
def hide_help_info(self):
self.hide_widget_on_top()
def show_step_info(self, msg):
self.hide_step_info()
widget = StepInfo(msg)
self.show_widget_on_top(widget, width=60,
height=14,
align="center",
valign="middle",
min_height=10)
def hide_step_info(self):
self.hide_widget_on_top()
def show_selector_info(self, title, opts, cb):
widget = Selector(title, opts, cb)
self.show_widget_on_top(widget, width=50, height=10)
#.........这里部分代码省略.........
示例14: CursesInterface
class CursesInterface(WidgetWrap):
"""
Creates a curses interface for the program, providing functions to draw
all the components of the UI.
Provides a facade API to draw the representation of the
:class:`~turses.models.TimelineList`, help :class:`HelpBuffer`
and intro :class:`Banner` screens.
"""
def __init__(self):
self._editor = None
# header
header = TabsWidget()
# body
body = Banner()
# footer
self._status_bar = configuration.styles.get('status_bar', False)
if self._status_bar:
footer = StatusBar('')
else:
footer = None
self.frame = Frame(body,
header=header,
footer=footer)
super(CursesInterface, self).__init__(self.frame)
def _build_overlay_widget(self,
top_w,
align,
width,
valign,
height,
min_width,
min_height):
return Overlay(top_w=Filler(top_w),
bottom_w=self.frame,
align=align,
width=width,
valign=valign,
height=height,
min_width=width,
min_height=height)
# -- Modes ----------------------------------------------------------------
def draw_timelines(self, timelines):
self.frame.body = TimelinesBuffer(timelines)
self.frame.set_body(self.frame.body)
def show_info(self):
self.frame.header.clear()
self.frame.body = Banner()
self.frame.set_body(self.frame.body)
def show_help(self):
self.clear_header()
self.status_info_message(_('type <esc> to leave the help page.'))
self.frame.body = HelpBuffer()
self.frame.set_body(self.frame.body)
# -- Header ---------------------------------------------------------------
def clear_header(self):
self.frame.header.clear()
def set_tab_names(self, names):
self.frame.header.set_tabs(names)
self.frame.set_header(self.frame.header)
def activate_tab(self, index):
self.frame.header.set_active_tab(index)
self.frame.set_header(self.frame.header)
def highlight_tabs(self, indexes):
self.frame.header.set_visible_tabs(indexes)
# -- Footer ---------------------------------------------------------------
@property
def can_write_status(self):
if self._status_bar:
if self.frame.footer is None:
self.frame.footer = StatusBar('')
return True
return False
def status_message(self, text):
if self.can_write_status:
self.frame.footer.message(text)
self.frame.set_footer(self.frame.footer)
def status_error_message(self, message):
if self.can_write_status:
self.frame.footer.error_message(message)
#.........这里部分代码省略.........
示例15: PegasusGUI
class PegasusGUI(WidgetWrap):
def __init__(self, header=None, body=None, footer=None):
_check_encoding() # Make sure terminal supports utf8
self.header = header if header else Header()
self.body = body if body else Banner()
self.footer = footer if footer else StatusBar('')
self.frame = Frame(self.body,
header=self.header,
footer=self.footer)
self.placement_view = None
super().__init__(self.frame)
def _build_overlay_widget(self,
top_w,
align,
width,
valign,
height,
min_width,
min_height):
return Overlay(top_w=Filler(top_w),
bottom_w=self.frame,
align=align,
width=width,
valign=valign,
height=height,
min_width=width,
min_height=height)
def show_widget_on_top(self,
widget,
width,
height,
align='center',
valign='middle',
min_height=0,
min_width=0):
"""Show `widget` on top of :attr:`frame`."""
self._w = self._build_overlay_widget(top_w=widget,
align=align,
width=width,
valign=valign,
height=height,
min_width=min_width,
min_height=min_height)
def focus_next(self):
self.frame.body.scroll_down()
def focus_previous(self):
self.frame.body.scroll_up()
def focus_first(self):
self.frame.body.scroll_top()
def focus_last(self):
self.frame.body.scroll_bottom()
def hide_widget_on_top(self):
"""Hide the topmost widget (if any)."""
self._w = self.frame
def show_help_info(self):
widget = HelpScreen()
self.show_widget_on_top(widget, width=80, height=22,
align="center", valign="middle",
min_height=10)
def hide_help_info(self):
self.hide_widget_on_top()
def show_step_info(self, msg, width=60, height=10):
self.hide_step_info()
widget = StepInfo(msg, height)
self.show_widget_on_top(widget, width=width, height=height + 1,
align="center",
valign="middle", min_height=10)
def hide_step_info(self):
self.hide_widget_on_top()
def show_selector_info(self, title, opts, cb):
widget = Selector(title, opts, cb)
self.show_widget_on_top(widget, width=50, height=10)
def hide_selector_info(self):
self.hide_widget_on_top()
def show_fatal_error_message(self, msg, cb):
w = InfoDialog(msg, cb)
self.show_widget_on_top(w, width=50, height=20)
def show_password_input(self, title, cb):
widget = PasswordInput(title, cb)
self.show_widget_on_top(widget, width=50, height=10)
def hide_show_password_input(self):
#.........这里部分代码省略.........