當前位置: 首頁>>代碼示例>>Python>>正文


Python gobject.io_add_watch方法代碼示例

本文整理匯總了Python中gobject.io_add_watch方法的典型用法代碼示例。如果您正苦於以下問題:Python gobject.io_add_watch方法的具體用法?Python gobject.io_add_watch怎麽用?Python gobject.io_add_watch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gobject的用法示例。


在下文中一共展示了gobject.io_add_watch方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: inputhook

# 需要導入模塊: import gobject [as 別名]
# 或者: from gobject import io_add_watch [as 別名]
def inputhook(context):
    """
    When the eventloop of prompt-toolkit is idle, call this inputhook.

    This will run the GTK main loop until the file descriptor
    `context.fileno()` becomes ready.

    :param context: An `InputHookContext` instance.
    """

    def _main_quit(*a, **kw):
        gtk.main_quit()
        return False

    gobject.io_add_watch(context.fileno(), gobject.IO_IN, _main_quit)
    gtk.main() 
開發者ID:prompt-toolkit,項目名稱:python-prompt-toolkit,代碼行數:18,代碼來源:inputhook.py

示例2: inputhook_gtk

# 需要導入模塊: import gobject [as 別名]
# 或者: from gobject import io_add_watch [as 別名]
def inputhook_gtk():
    gobject.io_add_watch(sys.stdin, gobject.IO_IN, _main_quit)
    gtk.main()
    return 0 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:6,代碼來源:inputhookgtk.py

示例3: _install_transport_ready

# 需要導入模塊: import gobject [as 別名]
# 或者: from gobject import io_add_watch [as 別名]
def _install_transport_ready(self):
        if ('r' in self.access_type):
            io_event = gobject.IO_IN
        else:
            io_event = gobject.IO_OUT

        self.tag = gobject.io_add_watch(self.fd, io_event,
                                        self._transport_ready_handler) 
開發者ID:liamw9534,項目名稱:bt-manager,代碼行數:10,代碼來源:audio.py

示例4: incoming_connection

# 需要導入模塊: import gobject [as 別名]
# 或者: from gobject import io_add_watch [as 別名]
def incoming_connection(self, source, condition):
        sock, info = self.server_sock.accept()
        address, psm = info

        self.add_text("\naccepted connection from %s" % str(address))

        # add new connection to list of peers
        self.peers[address] = sock
        self.addresses[sock] = address

        source = gobject.io_add_watch (sock, gobject.IO_IN, self.data_ready)
        self.sources[address] = source
        return True 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:15,代碼來源:bluezchat.py

示例5: start_server

# 需要導入模塊: import gobject [as 別名]
# 或者: from gobject import io_add_watch [as 別名]
def start_server(self):
        self.server_sock = bluetooth.BluetoothSocket (bluetooth.L2CAP)
        self.server_sock.bind(("",0x1001))
        self.server_sock.listen(1)

        gobject.io_add_watch(self.server_sock, 
                gobject.IO_IN, self.incoming_connection) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:9,代碼來源:bluezchat.py

示例6: _handleSignals

# 需要導入模塊: import gobject [as 別名]
# 或者: from gobject import io_add_watch [as 別名]
def _handleSignals(self):
            # Let the base class do its thing, but pygtk is probably
            # going to stomp on us so go beyond that and set up some
            # signal handling which pygtk won't mess with.  This would
            # be better done by letting this reactor select a
            # different implementation of installHandler for
            # _SIGCHLDWaker to use.  Then, at least, we could fall
            # back to our extension module.  See #4286.
            from twisted.internet.process import reapAllProcesses as _reapAllProcesses
            base._SignalReactorMixin._handleSignals(self)
            signal.signal(signal.SIGCHLD, lambda *a: self.callFromThread(_reapAllProcesses))
            if getattr(signal, "siginterrupt", None) is not None:
                signal.siginterrupt(signal.SIGCHLD, False)
            # Like the base, reap processes now in case a process
            # exited before the handlers above were installed.
            _reapAllProcesses()

    # The input_add function in pygtk1 checks for objects with a
    # 'fileno' method and, if present, uses the result of that method
    # as the input source. The pygtk2 input_add does not do this. The
    # function below replicates the pygtk1 functionality.

    # In addition, pygtk maps gtk.input_add to _gobject.io_add_watch, and
    # g_io_add_watch() takes different condition bitfields than
    # gtk_input_add(). We use g_io_add_watch() here in case pygtk fixes this
    # bug. 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:28,代碼來源:gtk2reactor.py

示例7: input_add

# 需要導入模塊: import gobject [as 別名]
# 或者: from gobject import io_add_watch [as 別名]
def input_add(self, source, condition, callback):
        if hasattr(source, 'fileno'):
            # handle python objects
            def wrapper(source, condition, real_s=source, real_cb=callback):
                return real_cb(real_s, condition)
            return gobject.io_add_watch(source.fileno(), condition, wrapper)
        else:
            return gobject.io_add_watch(source, condition, callback) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:10,代碼來源:gtk2reactor.py

示例8: register_intr_sock

# 需要導入模塊: import gobject [as 別名]
# 或者: from gobject import io_add_watch [as 別名]
def register_intr_sock(self, sock):
        self.sock = sock
        for dev in self.devs:
            gobject.io_add_watch(dev, gobject.IO_IN, self.ev_cb) 
開發者ID:lvht,項目名稱:btk,代碼行數:6,代碼來源:inputdev.py

示例9: __init__

# 需要導入模塊: import gobject [as 別名]
# 或者: from gobject import io_add_watch [as 別名]
def __init__(self, useGtk=True):
        self.context = gobject.main_context_default()
        self.loop = gobject.MainLoop()
        posixbase.PosixReactorBase.__init__(self)
        # pre 2.3.91 the glib iteration and mainloop functions didn't release
        # global interpreter lock, thus breaking thread and signal support.
        if (hasattr(gobject, "pygtk_version") and gobject.pygtk_version >= (2, 3, 91)
            and not useGtk):
            self.__pending = self.context.pending
            self.__iteration = self.context.iteration
            self.__crash = self.loop.quit
            self.__run = self.loop.run
        else:
            import gtk
            self.__pending = gtk.events_pending
            self.__iteration = gtk.main_iteration
            self.__crash = _our_mainquit
            self.__run = gtk.main

    # The input_add function in pygtk1 checks for objects with a
    # 'fileno' method and, if present, uses the result of that method
    # as the input source. The pygtk2 input_add does not do this. The
    # function below replicates the pygtk1 functionality.

    # In addition, pygtk maps gtk.input_add to _gobject.io_add_watch, and
    # g_io_add_watch() takes different condition bitfields than
    # gtk_input_add(). We use g_io_add_watch() here in case pygtk fixes this
    # bug. 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:30,代碼來源:gtk2reactor.py


注:本文中的gobject.io_add_watch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。