本文整理匯總了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)