本文整理汇总了Python中urwid.Frame.set_body方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.set_body方法的具体用法?Python Frame.set_body怎么用?Python Frame.set_body使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urwid.Frame
的用法示例。
在下文中一共展示了Frame.set_body方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CursesInterface
# 需要导入模块: from urwid import Frame [as 别名]
# 或者: from urwid.Frame import set_body [as 别名]
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)
#.........这里部分代码省略.........
示例2: PegasusGUI
# 需要导入模块: from urwid import Frame [as 别名]
# 或者: from urwid.Frame import set_body [as 别名]
#.........这里部分代码省略.........
self.frame.body.flash_reset()
def status_message(self, text):
self.frame.footer.message(text)
self.frame.set_footer(self.frame.footer)
def status_error_message(self, message):
self.frame.footer.error_message(message)
def status_info_message(self, message):
self.frame.footer.info_message(
"{}\N{HORIZONTAL ELLIPSIS}".format(message))
def set_dashboard_url(self, ip, user, password):
self.frame.footer.set_dashboard_url(ip, user, password)
def set_jujugui_url(self, ip):
self.frame.footer.set_jujugui_url(ip)
def set_openstack_rel(self, text):
self.frame.footer.set_openstack_rel(text)
def clear_status(self):
self.frame.footer = None
self.frame.set_footer(self.frame.footer)
def render_services_view(self, nodes, juju_state, maas_state, config,
**kwargs):
if self.services_view is None:
self.services_view = ServicesView(nodes, juju_state, maas_state,
config)
self.services_view.update(nodes)
self.frame.set_body(self.services_view)
self.header.set_show_add_units_hotkey(True)
def render_node_install_wait(self, message=None, **kwargs):
self.frame.body = NodeInstallWaitMode(message, **kwargs)
self.frame.set_body(self.frame.body)
def render_placement_view(self, loop, config, cb):
""" render placement view
:param cb: deploy callback trigger
"""
if self.placement_view is None:
assert self.controller is not None
pc = self.controller.placement_controller
self.placement_view = PlacementView(self, pc, loop,
config, cb)
self.placement_view.update()
self.frame.body = self.placement_view
def render_machine_wait_view(self, config):
if self.machine_wait_view is None:
self.machine_wait_view = MachineWaitView(
self, self.current_installer, config)
self.machine_wait_view.update()
self.frame.body = self.machine_wait_view
def render_add_services_dialog(self, deploy_cb, cancel_cb):
def reset():
self.add_services_dialog = None
def cancel():
reset()
示例3: PegasusGUI
# 需要导入模块: from urwid import Frame [as 别名]
# 或者: from urwid.Frame import set_body [as 别名]
#.........这里部分代码省略.........
self.frame.body.flash("{}\N{HORIZONTAL ELLIPSIS}".format(msg))
def flash_reset(self):
self.frame.body.flash_reset()
def status_message(self, text):
self.frame.footer.message(text)
self.frame.set_footer(self.frame.footer)
def status_error_message(self, message):
self.frame.footer.error_message(message)
def status_info_message(self, message):
self.frame.footer.info_message("{}\N{HORIZONTAL ELLIPSIS}".format(message))
def set_dashboard_url(self, ip, user, password):
self.frame.footer.set_dashboard_url(ip, user, password)
def set_jujugui_url(self, ip):
self.frame.footer.set_jujugui_url(ip)
def set_openstack_rel(self, release):
self.frame.header.set_openstack_rel(release)
def clear_status(self):
self.frame.footer = None
self.frame.set_footer(self.frame.footer)
def render_services_view(self, nodes, juju_state, maas_state, config, **kwargs):
if self.services_view is None:
self.services_view = ServicesView(nodes, juju_state, maas_state, config)
self.services_view.update(nodes)
self.frame.set_body(self.services_view)
self.header.set_show_add_units_hotkey(True)
dc = config.getopt("deploy_complete")
dcstr = "complete" if dc else "pending"
rc = config.getopt("relations_complete")
rcstr = "complete" if rc else "pending"
ppc = config.getopt("postproc_complete")
ppcstr = "complete" if ppc else "pending"
self.status_info_message(
"Status: Deployments {}, " "Relations {}, " "Post-processing {} ".format(dcstr, rcstr, ppcstr)
)
def render_node_install_wait(self, message=None, **kwargs):
self.frame.body = NodeInstallWaitMode(message, **kwargs)
def render_placement_view(self, loop, config, cb):
""" render placement view
:param cb: deploy callback trigger
"""
if self.placement_view is None:
assert self.controller is not None
pc = self.controller.placement_controller
self.placement_view = PlacementView(self, pc, loop, config, cb)
self.placement_view.update()
self.frame.body = self.placement_view
def render_machine_wait_view(self, config):
if self.machine_wait_view is None:
self.machine_wait_view = MachineWaitView(self, self.current_installer, config)
self.machine_wait_view.update()
self.frame.body = self.machine_wait_view
示例4: PegasusGUI
# 需要导入模块: from urwid import Frame [as 别名]
# 或者: from urwid.Frame import set_body [as 别名]
#.........这里部分代码省略.........
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):
self.hide_widget_on_top()
def show_maas_input(self, title, cb):
widget = MaasServerInput(title, cb)
self.show_widget_on_top(widget, width=50, height=10)
def hide_show_maas_input(self):
self.hide_widget_on_top()
def show_dhcp_range(self, range_low, range_high, title, cb):
widget = DhcpRangeInput(range_low, range_high, title, cb)
self.show_widget_on_top(widget, width=50, height=10)
def hide_show_dhcp_range(self):
self.hide_widget_on_top()
def show_landscape_input(self, title, cb):
widget = LandscapeInput(title, cb)
self.show_widget_on_top(widget, width=50, height=10)
def hide_show_landscape_input(self):
self.hide_widget_on_top()
def show_add_charm_info(self, charms, cb):
widget = AddCharmDialog(charms, cb)
self.show_widget_on_top(widget, width=50, height=10)
def hide_add_charm_info(self):
self.hide_widget_on_top()
def set_pending_deploys(self, pending_charms):
self.frame.footer.set_pending_deploys(pending_charms)
def status_message(self, text):
self.frame.footer.message(text)
self.frame.set_footer(self.frame.footer)
def status_error_message(self, message):
self.frame.footer.error_message(message)
def status_info_message(self, message):
self.frame.footer.info_message(message)
def status_dashboard_url(self, ip):
self.frame.footer.set_dashboard_url(ip)
def status_jujugui_url(self, ip):
self.frame.footer.set_jujugui_url(ip)
def status_openstack_rel(self, text):
self.frame.footer.set_openstack_rel(text)
def clear_status(self):
self.frame.footer = None
self.frame.set_footer(self.frame.footer)
def render_nodes(self, nodes, juju_state, maas_state, **kwargs):
self.frame.body = NodeViewMode(nodes, juju_state, maas_state)
self.frame.set_body(self.frame.body)
self.header.set_show_add_units_hotkey(True)
def render_node_install_wait(self, **kwargs):
self.frame.body = NodeInstallWaitMode(**kwargs)
self.frame.set_body(self.frame.body)
def render_placement_view(self, display_controller,
placement_controller):
if self.placement_view is None:
self.placement_view = PlacementView(display_controller,
placement_controller)
self.placement_view.update()
self.frame.body = self.placement_view
示例5: PegasusGUI
# 需要导入模块: from urwid import Frame [as 别名]
# 或者: from urwid.Frame import set_body [as 别名]
#.........这里部分代码省略.........
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=None):
self.hide_step_info()
widget = StepInfo(msg)
self.show_widget_on_top(widget, width=50, height=3, align="center",
valign="middle", min_height=10)
def hide_step_info(self):
self.hide_widget_on_top()
def show_add_charm_info(self, charms, cb):
widget = AddCharmDialog(charms, cb)
self.show_widget_on_top(widget, width=50, height=10)
def hide_add_charm_info(self):
self.hide_widget_on_top()
def set_pending_deploys(self, pending_charms):
self.frame.footer.set_pending_deploys(pending_charms)
def status_message(self, text):
self.frame.footer.message(text)
self.frame.set_footer(self.frame.footer)
def status_error_message(self, message):
self.frame.footer.error_message(message)
def status_info_message(self, message):
self.frame.footer.info_message(message)
def status_dashboard_url(self, ip):
self.frame.footer.set_dashboard_url(ip)
def status_jujugui_url(self, ip):
self.frame.footer.set_jujugui_url(ip)
def clear_status(self):
self.frame.footer = None
self.frame.set_footer(self.frame.footer)
def render_nodes(self, nodes, juju_state, maas_state, **kwargs):
self.frame.body = NodeViewMode(nodes, juju_state, maas_state)
self.frame.set_body(self.frame.body)
def render_node_install_wait(self, **kwargs):
self.frame.body = NodeInstallWaitMode()
self.frame.set_body(self.frame.body)