I meant connecting to a PyQt program from Artiq.
I've now got a minimal PyQt version of the message printing driver from the Artiq documentation working, although it doesn't behave at all gracefully when the PyQt window is closed, so advice on handling termination is welcome.
import asyncio
from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel
from quamash import QEventLoop
from artiq.protocols.pc_rpc import Server
class Hello(QMainWindow):
def __init__(self, app):
super().__init__()
loop = QEventLoop(app)
asyncio.set_event_loop(loop)
self.message_label = QLabel()
self.setCentralWidget(self.message_label)
self.show()
try:
server = Server({"hello": self}, None, True)
loop.run_until_complete(server.start("::1", 3249))
try:
loop.run_until_complete(server.wait_terminate())
finally:
loop.run_until_complete(server.stop())
finally:
loop.close()
def message(self, msg):
self.message_label.setText(msg)
def main():
Hello(QApplication(["Hello"]))
if __name__ == "__main__":
main()