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


Python GLib.io_add_watch方法代碼示例

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


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

示例1: NewConnection

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import io_add_watch [as 別名]
def NewConnection(self, device, fd, fd_properties):
        print("New control connection (%s, %d, %s)" % (device, fd, fd_properties))
        self.conns[device] = HIDConnection(fd)

        def new_intr_conn(ssock, ip_type):
            sock, info = ssock.accept()
            print("interrupt connection:", info)
            self.conns[device].register_intr_socks(sock)
            return False

        GLib.io_add_watch(self.sock, GLib.IO_IN, new_intr_conn) 
開發者ID:lvht,項目名稱:btk,代碼行數:13,代碼來源:btk.py

示例2: register_server_socket

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import io_add_watch [as 別名]
def register_server_socket(self, fileno):
        return GLib.io_add_watch(fileno, GLib.IO_IN, self.handle_connection) 
開發者ID:mopidy,項目名稱:mopidy-mpd,代碼行數:4,代碼來源:network.py

示例3: enable_recv

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import io_add_watch [as 別名]
def enable_recv(self):
        if self.recv_id is not None:
            return

        try:
            self.recv_id = GLib.io_add_watch(
                self._sock.fileno(),
                GLib.IO_IN | GLib.IO_ERR | GLib.IO_HUP,
                self.recv_callback,
            )
        except OSError as exc:
            self.stop(f"Problem with connection: {exc}") 
開發者ID:mopidy,項目名稱:mopidy-mpd,代碼行數:14,代碼來源:network.py

示例4: enable_send

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import io_add_watch [as 別名]
def enable_send(self):
        if self.send_id is not None:
            return

        try:
            self.send_id = GLib.io_add_watch(
                self._sock.fileno(),
                GLib.IO_OUT | GLib.IO_ERR | GLib.IO_HUP,
                self.send_callback,
            )
        except OSError as exc:
            self.stop(f"Problem with connection: {exc}") 
開發者ID:mopidy,項目名稱:mopidy-mpd,代碼行數:14,代碼來源:network.py

示例5: inputhook_gtk3

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

示例6: __init__

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import io_add_watch [as 別名]
def __init__(self, ctrl_fd):
        self.ctrl_fd = ctrl_fd

        self.ctrl_io_id = GLib.io_add_watch(
            self.ctrl_fd,
            GLib.IO_IN,
            self.ctrl_data_cb
        ) 
開發者ID:lvht,項目名稱:btk,代碼行數:10,代碼來源:btk.py

示例7: __init__

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import io_add_watch [as 別名]
def __init__(self, callback):
        super().__init__()

        # Worker process to handle counting.
        self.counting = False
        self.count_pending_text = None
        self.parent_conn, child_conn = Pipe()
        Process(target=self.do_count, args=(child_conn,), daemon=True).start()
        GLib.io_add_watch(
            self.parent_conn.fileno(), GLib.PRIORITY_LOW, GLib.IO_IN, self.on_counted, callback) 
開發者ID:ApostropheEditor,項目名稱:Apostrophe,代碼行數:12,代碼來源:stats_counter.py

示例8: gtk_watch_client

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import io_add_watch [as 別名]
def gtk_watch_client(client):
    # watch client's websocket in GTK main loop
    # `or True` is for always returning True to keep watching
    GLib.io_add_watch(client.ws, GLib.IO_IN, lambda ws, _: client.on_message() or True)
    GLib.io_add_watch(client.ws, GLib.IO_ERR, lambda ws, _: client.subscriber.on_sock_error() or True)
    GLib.io_add_watch(client.ws, GLib.IO_HUP, lambda ws, _: client.disconnect() or True) 
開發者ID:Gjum,項目名稱:gagar,代碼行數:8,代碼來源:main.py


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