当前位置: 首页>>代码示例>>Python>>正文


Python urwid.Overlay方法代码示例

本文整理汇总了Python中urwid.Overlay方法的典型用法代码示例。如果您正苦于以下问题:Python urwid.Overlay方法的具体用法?Python urwid.Overlay怎么用?Python urwid.Overlay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在urwid的用法示例。


在下文中一共展示了urwid.Overlay方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Overlay [as 别名]
def __init__(self, controller: Any, question: Any,
                 success_callback: Callable[[], bool]):
        self.controller = controller
        self.success_callback = success_callback
        yes = urwid.Button('Yes', self.exit_popup_yes)
        no = urwid.Button('No', self.exit_popup_no)
        yes._w = urwid.AttrMap(urwid.SelectableIcon(
            'Yes', 4), None, 'selected')
        no._w = urwid.AttrMap(urwid.SelectableIcon(
            'No', 4), None, 'selected')
        display_widget = urwid.GridFlow([yes, no], 3, 5, 1, 'center')
        wrapped_widget = urwid.WidgetWrap(display_widget)
        prompt = urwid.LineBox(
            urwid.ListBox(
                urwid.SimpleFocusListWalker(
                    [question, urwid.Divider(), wrapped_widget]
                )))
        urwid.Overlay.__init__(self, prompt, self.controller.view,
                               align="left", valign="top",
                               width=self.controller.view.LEFT_WIDTH + 1,
                               height=8) 
开发者ID:zulip,项目名称:zulip-terminal,代码行数:23,代码来源:views.py

示例2: quote_view_action

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Overlay [as 别名]
def quote_view_action(self, button, message):
        """
        Callback function to view a quote from the message object menu.
        """
        widget = OptionsMenu(
            ActionBox(urwid.SimpleFocusListWalker(self.make_message_body(message))),
            **self.frame_theme(">>%d" % message["post_id"])
        )

        self.loop.widget = urwid.Overlay(
            widget, self.loop.widget,
            align=("relative", 50),
            valign=("relative", 50),
            width=("relative", 98),
            height=("relative", 60)
        ) 
开发者ID:bbj-dev,项目名称:bbj,代码行数:18,代码来源:main.py

示例3: search_prompt

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Overlay [as 别名]
def search_prompt(self):
        if self.mode == "index":
            callback = self.search_index_callback
        elif self.mode == "thread":
            callback = self.search_thread_callback
        else:
            return

        popup = OptionsMenu(
            urwid.ListBox(
                urwid.SimpleFocusListWalker([
                    urwid.Text(("button", "Enter a query:")),
                    urwid.AttrMap(StringPrompt(callback), "opt_prompt"),
                    urwid.Text("Use a blank query to reset the {}.".format(self.mode))
                ])),
            **self.frame_theme())

        self.loop.widget = urwid.Overlay(
            popup, self.loop.widget,
            align=("relative", 50),
            valign=("relative", 25 if self.window_split else 50),
            width=("relative", 40), height=6) 
开发者ID:bbj-dev,项目名称:bbj,代码行数:24,代码来源:main.py

示例4: formatting_help

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Overlay [as 别名]
def formatting_help(self, *_):
        """
        Pops a help window for formatting directives.
        """
        # we can "recycle" the server's formatting abilities to
        # use the same syntax for the help text itself
        message = network.fake_message(
            "\n\n".join(format_help), format="sequential")

        widget = OptionsMenu(
            urwid.ListBox(urwid.SimpleFocusListWalker(app.make_message_body(message, True))),
            **self.frame_theme("Formatting Help")
        )

        va = 5 if self.window_split else 50
        vh = 45 if self.window_split else 75
        app.loop.widget = urwid.Overlay(
            widget, app.loop.widget,
            align=("relative", 50),
            valign=("relative", va),
            width=self.prefs["max_text_width"],
            height=("relative", vh)
        ) 
开发者ID:bbj-dev,项目名称:bbj,代码行数:25,代码来源:main.py

示例5: test_shards_bug

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Overlay [as 别名]
def test_shards_bug(self):
        scrl = Scrollable(
            urwid.Pile([urwid.Columns([urwid.Text("text")] * 3)] * 3)
        )
        sb = ScrollBar(scrl, thumb_char='#', trough_char='|', width=3)
        area = urwid.Overlay(urwid.SolidFill("O"), sb, "center", 4, "middle", 5)

        self.check(area, (10, 5), cursor_pos=(), text=(
            'tetOOOO###',
            'xttOOOO###',
            'tetOOOO###',
            'xttOOOO###',
            'tetOOOO|||',
        ))

    # https://github.com/urwid/urwid/issues/226#issuecomment-437176837 
开发者ID:rndusr,项目名称:stig,代码行数:18,代码来源:scroll_test.py

示例6: test_overlay

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Overlay [as 别名]
def test_overlay(self):
        s1 = urwid.SolidFill(u'1')
        s2 = urwid.SolidFill(u'2')
        o = urwid.Overlay(s1, s2,
            'center', ('relative', 50), 'middle', ('relative', 50))
        self.assertEqual(o.focus, s1)
        self.assertEqual(o.focus_position, 1)
        self.assertRaises(IndexError, lambda: setattr(o, 'focus_position',
            None))
        self.assertRaises(IndexError, lambda: setattr(o, 'focus_position', 2))

        self.assertEqual(o.contents[0], (s2,
            urwid.Overlay._DEFAULT_BOTTOM_OPTIONS))
        self.assertEqual(o.contents[1], (s1, (
            'center', None, 'relative', 50, None, 0, 0,
            'middle', None, 'relative', 50, None, 0, 0))) 
开发者ID:AnyMesh,项目名称:anyMesh-Python,代码行数:18,代码来源:test_container.py

示例7: test_focus_path

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Overlay [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]) 
开发者ID:AnyMesh,项目名称:anyMesh-Python,代码行数:26,代码来源:test_container.py

示例8: _showSearchView

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Overlay [as 别名]
def _showSearchView(self):

        self.searchView = SearchViewUrwid(self._callbackSearchFieldChange)

        # show search view as an overlay
        overlayView = urwid.Overlay(self.searchView.get(),
                                    self.mainFrame,
                                    align="center",
                                    width=("relative", 80),
                                    min_width=80,
                                    valign="middle",
                                    height=("relative", 5),
                                    min_height=5)
        self.mainLoop.widget = overlayView
        self.inSearchView = True

    # internal function that shows the sensor urwid objects given
    # by a page index 
开发者ID:sqall01,项目名称:alertR,代码行数:20,代码来源:screen.py

示例9: openOverlay

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Overlay [as 别名]
def openOverlay(widget, title=None, height=('relative', 50), width=('relative', 50)):
    if widget.sizing() == {'flow'}:
        height = 'pack'
    box = urwid.LineBox(widget, title or widget.title)
    overlay = urwid.Overlay(box, mainwidget, 'center', width, 'middle', height)
    loop.widget = overlay 
开发者ID:ids1024,项目名称:wikicurses,代码行数:8,代码来源:main.py

示例10: show_pop_up

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Overlay [as 别名]
def show_pop_up(self, to_show: Any) -> None:
        double_lines = dict(tlcorner='╔', tline='═', trcorner='╗',
                            rline='║', lline='║',
                            blcorner='╚', bline='═', brcorner='╝')
        self.loop.widget = urwid.Overlay(
            urwid.LineBox(to_show,
                          to_show.title,
                          **double_lines),
            self.view,
            align='center',
            valign='middle',
            # +2 to both of the following, due to LineBox
            width=to_show.width + 2,
            height=to_show.height + 2,
        ) 
开发者ID:zulip,项目名称:zulip-terminal,代码行数:17,代码来源:core.py

示例11: show_shutdown_dialog

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Overlay [as 别名]
def show_shutdown_dialog(self, exit_code):
        self.frame.body = Overlay(ShutdownView(exit_code),
                                  self.frame.body,
                                  'center', ('relative', 45),
                                  'middle', 'pack') 
开发者ID:conjure-up,项目名称:conjure-up,代码行数:7,代码来源:__init__.py

示例12: overlay_p

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Overlay [as 别名]
def overlay_p(self):
        """
        Return True or False if the current widget is an overlay.
        """
        return isinstance(self.loop.widget, urwid.Overlay) 
开发者ID:bbj-dev,项目名称:bbj,代码行数:7,代码来源:main.py

示例13: remove_overlays

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Overlay [as 别名]
def remove_overlays(self, *_):
        """
        Remove ALL urwid.Overlay objects which are currently covering the base
        widget.
        """
        while True:
            try:
                self.loop.widget = self.loop.widget[0]
            except:
                break 
开发者ID:bbj-dev,项目名称:bbj,代码行数:12,代码来源:main.py

示例14: quote_view_menu

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Overlay [as 别名]
def quote_view_menu(self, button, post_ids):
        """
        Receives a list of quote ids and makes a frilly menu to pick one to view.
        It retrieves messages objects from the thread and attaches them to a
        callback to `quote_view_action`
        """
        buttons = []
        for pid in post_ids:
            try:
                message = self.thread["messages"][pid]
                if len(post_ids) == 1:
                    return self.quote_view_action(button, message)
                author = self.usermap[message["author"]]
                label = [
                    ("button", ">>%d " % pid),
                    "(",
                    (str(author["color"]),
                     author["user_name"]),
                    ")"
                ]
                buttons.append(cute_button(label, self.quote_view_action, message))
            except IndexError:
                continue # users can submit >>29384234 garbage references

        widget = OptionsMenu(
            urwid.ListBox(urwid.SimpleFocusListWalker(buttons)),
            **self.frame_theme("View a Quote")
        )

        self.loop.widget = urwid.Overlay(
            widget, self.loop.widget,
            align=("relative", 50),
            valign=("relative", 50),
            height=len(buttons) + 3,
            width=30
        ) 
开发者ID:bbj-dev,项目名称:bbj,代码行数:38,代码来源:main.py

示例15: deletion_dialog

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Overlay [as 别名]
def deletion_dialog(self, button, message):
        """
        Prompts the user to confirm deletion of an item.
        This can delete either a thread or a post.
        """
        op = message["post_id"] == 0
        buttons = [
            urwid.Text(("bold", "Delete this %s?" % ("whole thread" if op else "post"))),
            urwid.Divider(),
            cute_button(("10" , ">> Yes"), lambda _: [
                network.message_delete(message["thread_id"], message["post_id"]),
                self.remove_overlays(),
                self.index() if op else self.refresh()
            ]),
            cute_button(("30", "<< No"), self.remove_overlays)
        ]

        # TODO: create a central routine for creating popups. this is getting really ridiculous
        popup = OptionsMenu(
            urwid.ListBox(urwid.SimpleFocusListWalker(buttons)),
            **self.frame_theme())

        self.loop.widget = urwid.Overlay(
            popup, self.loop.widget,
            align=("relative", 50),
            valign=("relative", 50),
            width=30, height=6) 
开发者ID:bbj-dev,项目名称:bbj,代码行数:29,代码来源:main.py


注:本文中的urwid.Overlay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。