• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python signals.connect_signal函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中urwid.signals.connect_signal函数的典型用法代码示例。如果您正苦于以下问题:Python connect_signal函数的具体用法?Python connect_signal怎么用?Python connect_signal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: __init__

 def __init__(self):
     """Initialize a screen that directly prints escape codes to an output
     terminal.
     """
     super(Screen, self).__init__()
     self._pal_escape = {}
     self._pal_attrspec = {}
     signals.connect_signal(self, UPDATE_PALETTE_ENTRY, 
         self._on_update_palette_entry)
     self.colors = 16 # FIXME: detect this
     self.has_underline = True # FIXME: detect this
     self.register_palette_entry( None, 'default','default')
     self._keyqueue = []
     self.prev_input_resize = 0
     self.set_input_timeouts()
     self.screen_buf = None
     self._screen_buf_canvas = None
     self._resized = False
     self.maxrow = None
     self.gpm_mev = None
     self.gpm_event_pending = False
     self._mouse_tracking_enabled = False
     self.last_bstate = 0
     self._setup_G1_done = False
     self._rows_used = None
     self._cy = 0
     term = os.environ.get('TERM', '')
     self.bright_is_bold = not term.startswith("xterm")
     self.back_color_erase = not term.startswith("screen")
     self._next_timeout = None
     self._term_output_file = sys.stdout
     self._term_input_file = sys.stdin
     # pipe for signalling external event loops about resize events
     self._resize_pipe_rd, self._resize_pipe_wr = os.pipe()
     fcntl.fcntl(self._resize_pipe_rd, fcntl.F_SETFL, os.O_NONBLOCK)
开发者ID:AnyMesh,项目名称:anyMesh-Python,代码行数:35,代码来源:raw_display.py


示例2: __init__

    def __init__(self, body):
        """
        body -- a ListWalker-like object that contains
            widgets to be displayed inside the list box
        """
        if hasattr(body,'get_focus'):
            self.body = body
        else:
            self.body = PollingListWalker(body)

        try:
            connect_signal(self.body, "modified", self._invalidate)
        except NameError:
            # our list walker has no modified signal so we must not
            # cache our canvases because we don't know when our
            # content has changed
            self.render = nocache_widget_render_instance(self)

        # offset_rows is the number of rows between the top of the view
        # and the top of the focused item
        self.offset_rows = 0
        # inset_fraction is used when the focused widget is off the 
        # top of the view.  it is the fraction of the widget cut off 
        # at the top.  (numerator, denominator)
        self.inset_fraction = (0,1)

        # pref_col is the preferred column for the cursor when moving
        # between widgets that use the cursor (edit boxes etc.)
        self.pref_col = 'left'

        # variable for delayed focus change used by set_focus
        self.set_focus_pending = 'first selectable'
        
        # variable for delayed valign change used by set_focus_valign
        self.set_focus_valign_pending = None
开发者ID:jmcb,项目名称:urwid,代码行数:35,代码来源:listbox.py


示例3: start

    def start(self):
        """
        Sets up the main loop, hooking into the event loop where necessary.
        Starts the :attr:`screen` if it hasn't already been started.

        If you want to control starting and stopping the event loop yourself,
        you should call this method before starting, and call `stop` once the
        loop has finished.  You may also use this method as a context manager,
        which will stop the loop automatically at the end of the block:

            with main_loop.start():
                ...

        Note that some event loop implementations don't handle exceptions
        specially if you manage the event loop yourself.  In particular, the
        Twisted and asyncio loops won't stop automatically when
        :exc:`ExitMainLoop` (or anything else) is raised.
        """
        self.screen.start()

        if self.handle_mouse:
            self.screen.set_mouse_tracking()

        if not hasattr(self.screen, "hook_event_loop"):
            raise CantUseExternalLoop("Screen {0!r} doesn't support external event loops")

        try:
            signals.connect_signal(self.screen, INPUT_DESCRIPTORS_CHANGED, self._reset_input_descriptors)
        except NameError:
            pass
        # watch our input descriptors
        self._reset_input_descriptors()
        self.idle_handle = self.event_loop.enter_idle(self.entering_idle)

        return StoppingContext(self)
开发者ID:thubaichaves,项目名称:pygestor,代码行数:35,代码来源:main_loop.py


示例4: __init__

    def __init__(self, label, on_press=None, user_data=None):
        """
        label -- markup for button label
        on_press, user_data -- shorthand for connect_signal()
            function call for a single callback

        Signals supported: 'click'
        Register signal handler with:
          connect_signal(button, 'click', callback [,user_data])
        where callback is callback(button [,user_data])
        Unregister signal handlers with:
          disconnect_signal(button, 'click', callback [,user_data])

        >>> Button(u"Ok")
        <Button selectable flow widget 'Ok'>
        >>> b = Button("Cancel")
        >>> b.render((15,), focus=True).text # ... = b in Python 3
        [...'< Cancel      >']
        """
        self._label = SelectableIcon("", 0)
        cols = Columns([
            ('fixed', 1, self.button_left),
            self._label,
            ('fixed', 1, self.button_right)],
            dividechars=1)
        self.__super.__init__(cols)

        # The old way of listening for a change was to pass the callback
        # in to the constructor.  Just convert it to the new way:
        if on_press:
            connect_signal(self, 'click', on_press, user_data)

        self.set_label(label)
开发者ID:eykd,项目名称:urwid,代码行数:33,代码来源:wimp.py


示例5: __init__

    def __init__(self, tab=None, ltab=None, loader=None, tree=False):
        self.header = urwid.Edit()

        if loader is None:
            loader = self.FoolLoader

        self.loader = loader
        self.tree = tree
        self.tab = tab
        self.ltab = ltab
        self.search = ''

        connect_signal(self.header, "change", self.update)

        self.fn = FirstNode(nome='')
        self.tw = urwid.TreeWalker(self.fn)
        self.listbox = urwid.TreeListBox(self.tw)

        self.listbox.offset_rows = 3

        self.footer = urwid.AttrWrap(urwid.Text(self.footer_text),
                                     'foot')

        self.view = urwid.Frame(
            urwid.AttrWrap(self.listbox, 'body'),
            header=urwid.AttrWrap(self.header, 'head'),
            footer=self.footer, focus_part='header')

        self.i = 1
开发者ID:thubaichaves,项目名称:pygestor,代码行数:29,代码来源:TreeList.py


示例6: connect_signal

    def connect_signal(self, signal):
        self._sig_response = None

        def _set_signal_response(widget, *args, **kwargs):
            self._sig_response = (args, kwargs)
        self._set_signal_response = _set_signal_response

        signals.connect_signal(self.term, signal, self._set_signal_response)
开发者ID:0xPr0xy,项目名称:blogger-cli,代码行数:8,代码来源:vterm_test.py


示例7: __init__

    def __init__(self, icon, label, on_press=None, user_data=None): 
        self._icon  = AttrMap(SelectableIcon(icon, 0), 'clip_dim')
        self._label = SelectableIcon(label, 0)

        cols = Columns([
            ('fixed', len(icon), self._icon),
            self._label],
            dividechars=1)
        WidgetWrap.__init__(self, cols)

        connect_signal(self, 'click', on_press, user_data)
开发者ID:ViktorNova,项目名称:python-cliplauncher,代码行数:11,代码来源:tracks.py


示例8: __init__

    def __init__(self,
                 label,
                 state=False,
                 has_mixed=False,
                 on_state_change=None,
                 user_data=None):
        """
        :param label: markup for check box label
        :param state: False, True or "mixed"
        :param has_mixed: True if "mixed" is a state to cycle through
        :param on_state_change: shorthand for connect_signal()
                                function call for a single callback
        :param user_data: user_data for on_state_change

        Signals supported: ``'change'``

        Register signal handler with::

          urwid.connect_signal(check_box, 'change', callback, user_data)

        where callback is callback(check_box, new_state [,user_data])
        Unregister signal handlers with::

          urwid.disconnect_signal(check_box, 'change', callback, user_data)

        >>> CheckBox(u"Confirm")
        <CheckBox selectable flow widget 'Confirm' state=False>
        >>> CheckBox(u"Yogourt", "mixed", True)
        <CheckBox selectable flow widget 'Yogourt' state='mixed'>
        >>> cb = CheckBox(u"Extra onions", True)
        >>> cb
        <CheckBox selectable flow widget 'Extra onions' state=True>
        >>> cb.render((20,), focus=True).text # ... = b in Python 3
        [...'[X] Extra onions    ']
        """
        self.__super.__init__(None)  # self.w set by set_state below
        self._label = Text("")
        self.has_mixed = has_mixed
        self._state = None
        # The old way of listening for a change was to pass the callback
        # in to the constructor.  Just convert it to the new way:
        if on_state_change:
            connect_signal(self, 'change', on_state_change, user_data)
        self.set_label(label)
        self.set_state(state)
开发者ID:horazont,项目名称:urwid,代码行数:45,代码来源:wimp.py


示例9: __init__

    def __init__(self):
        self.header = urwid.Edit()

        connect_signal(self.header, "change", self.update)

        self.carrega("lists_a", "osfab")

        self.listbox.offset_rows = 3

        self.footer = urwid.AttrWrap(urwid.Text(self.footer_text), "foot")

        self.view = urwid.Frame(
            urwid.AttrWrap(self.listbox, "body"),
            header=urwid.AttrWrap(self.header, "head"),
            footer=self.footer,
            focus_part="header",
        )

        self.i = 1
开发者ID:thubaichaves,项目名称:pygestor,代码行数:19,代码来源:browse.py


示例10: _run

    def _run(self):
        if self.handle_mouse:
            self.screen.set_mouse_tracking()

        if not hasattr(self.screen, 'get_input_descriptors'):
            return self._run_screen_event_loop()

        self.draw_screen()

        fd_handles = []
        def reset_input_descriptors(only_remove=False):
            for handle in fd_handles:
                self.event_loop.remove_watch_file(handle)
            if only_remove:
                del fd_handles[:]
            else:
                fd_handles[:] = [
                    self.event_loop.watch_file(fd, self._update)
                    for fd in self.screen.get_input_descriptors()]
            if not fd_handles and self._input_timeout is not None:
                self.event_loop.remove_alarm(self._input_timeout)

        try:
            signals.connect_signal(self.screen, INPUT_DESCRIPTORS_CHANGED,
                reset_input_descriptors)
        except NameError:
            pass
        # watch our input descriptors
        reset_input_descriptors()
        idle_handle = self.event_loop.enter_idle(self.entering_idle)

        # Go..
        self.event_loop.run()

        # tidy up
        self.event_loop.remove_enter_idle(idle_handle)
        reset_input_descriptors(True)
        signals.disconnect_signal(self.screen, INPUT_DESCRIPTORS_CHANGED,
            reset_input_descriptors)
开发者ID:Vockenroth,项目名称:ConnectFour,代码行数:39,代码来源:main_loop.py


示例11: __init__

    def __init__(self, label, state=False, has_mixed=False,
             on_state_change=None, user_data=None):
        """
        label -- markup for check box label
        state -- False, True or "mixed"
        has_mixed -- True if "mixed" is a state to cycle through
        on_state_change, user_data -- shorthand for connect_signal()
            function call for a single callback
        
        Signals supported: 'change'
        Register signal handler with:
          connect_signal(check_box, 'change', callback [,user_data])
        where callback is callback(check_box, new_state [,user_data])
        Unregister signal handlers with:
          disconnect_signal(check_box, 'change', callback [,user_data])

        >>> CheckBox("Confirm")
        <CheckBox selectable widget 'Confirm' state=False>
        >>> CheckBox("Yogourt", "mixed", True)
        <CheckBox selectable widget 'Yogourt' state='mixed'>
        >>> cb = CheckBox("Extra onions", True)
        >>> cb
        <CheckBox selectable widget 'Extra onions' state=True>
        >>> cb.render((20,), focus=True).text  # preview CheckBox
        ['[X] Extra onions    ']
        """
        self.__super.__init__(None) # self.w set by set_state below
        self._label = Text("")
        self.has_mixed = has_mixed
        self._state = None
        # The old way of listening for a change was to pass the callback
        # in to the constructor.  Just convert it to the new way:
        if on_state_change:
            connect_signal(self, 'change', on_state_change, user_data)
        self.set_label(label)
        self.set_state(state)
开发者ID:bakotaco,项目名称:urwid,代码行数:36,代码来源:wimp.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python signals.emit_signal函数代码示例发布时间:2022-05-27
下一篇:
Python escape.set_cursor_position函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap