Open ghistes opened 4 years ago
No, it's not currently possible. But I would like to support the use case and I'm open to a discussion about how to implement it.
For GTK in particular, I have this project but I haven't updated in awhile.
I can't really contribute to any discussion as I am pretty new to Python and don't know the ecosystem. But it maybe worth you can get some ideas from Perl's AnyEvent-module (https://metacpan.org/pod/AnyEvent).
I realize this is a slightly old thread, however I felt I should add that it is possible to combine with the event loop of Qt using asyncqt. The snippet below achieves just that.
from i3ipc.aio import Connection
from i3ipc import Event
from PyQt5.QtWidgets import QApplication, QWidget
from asyncqt import QEventLoop
import sys
import asyncio
def _print(conn, event):
print(event)
async def main():
i3 = await Connection(auto_reconnect=True).connect()
i3.on(Event.WINDOW, _print)
await i3.main()
if __name__ == '__main__':
app = QApplication(sys.argv)
loop = QEventLoop(app)
asyncio.set_event_loop(loop)
widget = QWidget()
widget.show()
with loop:
sys.exit(loop.run_until_complete(main()))
In case anyone is looking to combine with Qt.
Hi,
is it possible (and if it is how do you do it) to combine the event-loop from i3ipc with another event loop (gtk say) so that you could for example write a GUI-script that uses i3ipc?
Many thanks!