Skip to content

Commit 28c4d8c

Browse files
committedFeb 19, 2016
applets: attempt at fixing embedding bugs on Windows
1 parent fef7250 commit 28c4d8c

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed
 

‎artiq/applets/simple.py

+19-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22
import argparse
33
import asyncio
4+
import os
45

56
from quamash import QEventLoop, QtWidgets, QtGui, QtCore
67

@@ -130,19 +131,26 @@ def ipc_close(self):
130131

131132
def create_main_widget(self):
132133
self.main_widget = self.main_widget_class(self.args)
133-
# Qt window embedding is ridiculously buggy, and empirical testing
134-
# has shown that the following procedure must be followed exactly:
135-
# 1. applet creates widget
136-
# 2. applet creates native window without showing it, and get its ID
137-
# 3. applet sends the ID to host, host embeds the widget
138-
# 4. applet shows the widget
139-
# 5. parent resizes the widget
140134
if self.args.embed is not None:
141135
self.ipc.set_close_cb(self.main_widget.close)
142-
win_id = int(self.main_widget.winId())
143-
self.loop.run_until_complete(self.ipc.embed(win_id))
144-
self.main_widget.show()
145-
self.ipc.fix_initial_size()
136+
if os.name == "nt":
137+
self.main_widget.show()
138+
win_id = int(self.main_widget.winId())
139+
self.loop.run_until_complete(self.ipc.embed(win_id))
140+
else:
141+
# Qt window embedding is ridiculously buggy, and empirical
142+
# testing has shown that the following procedure must be
143+
# followed exactly on Linux:
144+
# 1. applet creates widget
145+
# 2. applet creates native window without showing it, and
146+
# gets its ID
147+
# 3. applet sends the ID to host, host embeds the widget
148+
# 4. applet shows the widget
149+
# 5. parent resizes the widget
150+
win_id = int(self.main_widget.winId())
151+
self.loop.run_until_complete(self.ipc.embed(win_id))
152+
self.main_widget.show()
153+
self.ipc.fix_initial_size()
146154
else:
147155
self.main_widget.show()
148156

0 commit comments

Comments
 (0)
Please sign in to comment.