|
1 | 1 | ##################################################################### |
2 | 2 | # # |
3 | | -# /main.pyw # |
| 3 | +# __main__.py # |
4 | 4 | # # |
5 | 5 | # Copyright 2014, Monash University # |
6 | 6 | # # |
|
10 | 10 | # the project for the full license. # |
11 | 11 | # # |
12 | 12 | ##################################################################### |
13 | | -from __future__ import division, unicode_literals, print_function, absolute_import |
14 | | -from labscript_utils import PY2 |
15 | | - |
16 | 13 | import os |
17 | 14 | import labscript_utils.excepthook |
18 | 15 |
|
19 | | -try: |
20 | | - from labscript_utils import check_version |
21 | | -except ImportError: |
22 | | - raise ImportError('Require labscript_utils > 2.1.0') |
23 | | - |
24 | | -check_version('labscript_utils', '2.15.0', '3') |
25 | | - |
26 | 16 | # Associate app windows with OS menu shortcuts: |
27 | 17 | import desktop_app |
28 | 18 | desktop_app.set_process_appid('runviewer') |
|
39 | 29 | import time |
40 | 30 | import threading |
41 | 31 | import logging |
42 | | -import socket |
43 | | -if PY2: |
44 | | - str = unicode |
45 | | - from Queue import Queue |
46 | | -else: |
47 | | - from queue import Queue |
| 32 | +from queue import Queue |
48 | 33 | import ast |
49 | 34 | import pprint |
50 | | - |
51 | 35 | import signal |
52 | | -# Quit on ctrl-c |
53 | | -signal.signal(signal.SIGINT, signal.SIG_DFL) |
54 | | - |
55 | | - |
56 | | -splash.update_text('importing Qt') |
57 | | -check_version('qtutils', '2.0.0', '3.0.0') |
58 | 36 |
|
59 | 37 | splash.update_text('importing labscript suite modules') |
60 | 38 | from labscript_utils.setup_logging import setup_logging |
|
65 | 43 | import labscript_utils.h5_lock |
66 | 44 | import h5py |
67 | 45 |
|
68 | | -# This must be bumped until after the h5_lock import |
69 | | -# This is because the check imports pyqtgraph, which imports h5py |
70 | | -# h5py must be imported after h5_lock, thus we do the check here |
71 | | -splash.update_text('importing pyqtgraph') |
72 | | -check_version('pyqtgraph', '0.9.10', '1') |
73 | | - |
| 46 | +# No splash update for Qt - the splash screen already imported it |
74 | 47 | from qtutils.qt.QtCore import * |
75 | 48 | from qtutils.qt.QtGui import * |
76 | 49 | from qtutils.qt.QtWidgets import * |
77 | 50 |
|
| 51 | +splash.update_text('importing pyqtgraph') |
| 52 | +import pyqtgraph as pg |
| 53 | + |
78 | 54 | splash.update_text('importing numpy') |
79 | 55 | import numpy |
80 | 56 | splash.update_text('importing scipy') |
81 | 57 | from scipy import interpolate |
82 | 58 |
|
83 | | -# must be imported after PySide/PyQt4 |
84 | | -import pyqtgraph as pg |
85 | 59 | pg.setConfigOption('background', 'w') |
86 | 60 | pg.setConfigOption('foreground', 'k') |
87 | 61 |
|
|
91 | 65 | from labscript_utils.connections import ConnectionTable |
92 | 66 | import labscript_devices |
93 | 67 |
|
94 | | -from labscript_utils.labconfig import LabConfig, config_prefix |
95 | | -check_version('labscript_utils', '2.11.0', '3') |
| 68 | +from labscript_utils.labconfig import LabConfig |
96 | 69 | from labscript_utils.ls_zprocess import ZMQServer, ProcessTree |
97 | 70 | process_tree = ProcessTree.instance() |
98 | 71 | process_tree.zlock_client.set_process_name('runviewer') |
@@ -1686,4 +1659,11 @@ def handler(self, h5_filepath): |
1686 | 1659 | def execute_program(): |
1687 | 1660 | qapplication.exec_() |
1688 | 1661 |
|
| 1662 | + # Let the interpreter run every 500ms so it sees Ctrl-C interrupts: |
| 1663 | + timer = QTimer() |
| 1664 | + timer.start(500) |
| 1665 | + timer.timeout.connect(lambda: None) |
| 1666 | + # Upon seeing a ctrl-c interrupt, quit the event loop |
| 1667 | + signal.signal(signal.SIGINT, lambda *args: qapplication.exit()) |
| 1668 | + |
1689 | 1669 | sys.exit(execute_program()) |
0 commit comments