1
0
forked from M-Labs/artiq

artiq_dashboard: style (NFC)

This commit is contained in:
Simon Renblad 2024-04-10 12:11:51 +08:00 committed by Sébastien Bourdeauducq
parent 43edffc67e
commit 7d9199a2ee

View File

@ -70,7 +70,7 @@ class MainWindow(QtWidgets.QMainWindow):
self.setWindowTitle("ARTIQ Dashboard - {}".format(server)) self.setWindowTitle("ARTIQ Dashboard - {}".format(server))
qfm = QtGui.QFontMetrics(self.font()) qfm = QtGui.QFontMetrics(self.font())
self.resize(140*qfm.averageCharWidth(), 38*qfm.lineSpacing()) self.resize(140 * qfm.averageCharWidth(), 38 * qfm.lineSpacing())
self.exit_request = asyncio.Event() self.exit_request = asyncio.Event()
@ -110,8 +110,8 @@ class MdiArea(QtWidgets.QMdiArea):
def paintEvent(self, event): def paintEvent(self, event):
QtWidgets.QMdiArea.paintEvent(self, event) QtWidgets.QMdiArea.paintEvent(self, event)
painter = QtGui.QPainter(self.viewport()) painter = QtGui.QPainter(self.viewport())
x = (self.width() - self.pixmap.width())//2 x = (self.width() - self.pixmap.width()) // 2
y = (self.height() - self.pixmap.height())//2 y = (self.height() - self.pixmap.height()) // 2
painter.setOpacity(0.5) painter.setOpacity(0.5)
painter.drawPixmap(x, y, self.pixmap) painter.drawPixmap(x, y, self.pixmap)
@ -128,9 +128,9 @@ def main():
if args.db_file is None: if args.db_file is None:
args.db_file = os.path.join(get_user_config_dir(), args.db_file = os.path.join(get_user_config_dir(),
"artiq_dashboard_{server}_{port}.pyon".format( "artiq_dashboard_{server}_{port}.pyon".format(
server=args.server.replace(":","."), server=args.server.replace(":", "."),
port=args.port_notify)) port=args.port_notify))
app = QtWidgets.QApplication(["ARTIQ Dashboard"]) app = QtWidgets.QApplication(["ARTIQ Dashboard"])
loop = QEventLoop(app) loop = QEventLoop(app)
@ -154,6 +154,7 @@ def main():
master_management.close_rpc() master_management.close_rpc()
disconnect_reported = False disconnect_reported = False
def report_disconnect(): def report_disconnect():
nonlocal disconnect_reported nonlocal disconnect_reported
if not disconnect_reported: if not disconnect_reported:
@ -167,8 +168,7 @@ def main():
("datasets", datasets.Model), ("datasets", datasets.Model),
("schedule", schedule.Model), ("schedule", schedule.Model),
("interactive_args", interactive_args.Model)): ("interactive_args", interactive_args.Model)):
subscriber = ModelSubscriber(notifier_name, modelf, subscriber = ModelSubscriber(notifier_name, modelf, report_disconnect)
report_disconnect)
loop.run_until_complete(subscriber.connect( loop.run_until_complete(subscriber.connect(
args.server, args.port_notify)) args.server, args.port_notify))
atexit_register_coroutine(subscriber.close, loop=loop) atexit_register_coroutine(subscriber.close, loop=loop)
@ -288,7 +288,6 @@ def main():
if d_log0 is not None: if d_log0 is not None:
main_window.tabifyDockWidget(d_schedule, d_log0) main_window.tabifyDockWidget(d_schedule, d_log0)
if server_name is not None: if server_name is not None:
server_description = server_name + " ({})".format(args.server) server_description = server_name + " ({})".format(args.server)
else: else:
@ -299,5 +298,6 @@ def main():
main_window.show() main_window.show()
loop.run_until_complete(main_window.exit_request.wait()) loop.run_until_complete(main_window.exit_request.wait())
if __name__ == "__main__": if __name__ == "__main__":
main() main()