本文整理汇总了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)
示例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)
示例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}")
示例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}")
示例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
示例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
)
示例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)
示例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)