|
3 | 3 | import sys
|
4 | 4 | import traceback
|
5 | 5 | from collections import OrderedDict
|
6 |
| -import numpy as np |
7 |
| -import larray as la |
8 | 6 |
|
9 | 7 | from qtpy.QtWidgets import QApplication, QMainWindow
|
| 8 | +import larray as la |
| 9 | + |
10 | 10 | from larray_editor.editor import REOPEN_LAST_FILE
|
11 | 11 |
|
12 | 12 | __all__ = ['view', 'edit', 'compare', 'REOPEN_LAST_FILE']
|
@@ -98,9 +98,10 @@ def edit(obj=None, title='', minvalue=None, maxvalue=None, readonly=False, depth
|
98 | 98 | >>> # will open an editor for a1 only
|
99 | 99 | >>> edit(a1) # doctest: +SKIP
|
100 | 100 | """
|
| 101 | + install_except_hook() |
| 102 | + |
101 | 103 | _app = QApplication.instance()
|
102 | 104 | if _app is None:
|
103 |
| - install_except_hook() |
104 | 105 | _app = qapplication()
|
105 | 106 | _app.setOrganizationName("LArray")
|
106 | 107 | _app.setApplicationName("Viewer")
|
@@ -131,8 +132,8 @@ def edit(obj=None, title='', minvalue=None, maxvalue=None, readonly=False, depth
|
131 | 132 | _app.exec_()
|
132 | 133 | else:
|
133 | 134 | dlg.exec_()
|
134 |
| - if parent is None: |
135 |
| - restore_except_hook() |
| 135 | + |
| 136 | + restore_except_hook() |
136 | 137 |
|
137 | 138 |
|
138 | 139 | def view(obj=None, title='', depth=0):
|
@@ -185,11 +186,12 @@ def compare(*args, **kwargs):
|
185 | 186 | >>> compare(a1, a2, title='first comparison') # doctest: +SKIP
|
186 | 187 | >>> compare(a1 + 1, a2, title='second comparison', names=['a1+1', 'a2']) # doctest: +SKIP
|
187 | 188 | """
|
| 189 | + install_except_hook() |
| 190 | + |
188 | 191 | title = kwargs.pop('title', '')
|
189 | 192 | names = kwargs.pop('names', None)
|
190 | 193 | _app = QApplication.instance()
|
191 | 194 | if _app is None:
|
192 |
| - install_except_hook() |
193 | 195 | _app = qapplication()
|
194 | 196 | parent = None
|
195 | 197 | else:
|
@@ -219,8 +221,8 @@ def get_name(i, obj, depth=0):
|
219 | 221 | dlg.show()
|
220 | 222 | else:
|
221 | 223 | dlg.exec_()
|
222 |
| - if parent is None: |
223 |
| - restore_except_hook() |
| 224 | + |
| 225 | + restore_except_hook() |
224 | 226 |
|
225 | 227 | _orig_except_hook = sys.excepthook
|
226 | 228 |
|
@@ -258,6 +260,7 @@ def restore_display_hook():
|
258 | 260 |
|
259 | 261 | if __name__ == "__main__":
|
260 | 262 | """Array editor test"""
|
| 263 | + import numpy as np |
261 | 264 |
|
262 | 265 | lipro = la.Axis(['P%02d' % i for i in range(1, 16)], 'lipro')
|
263 | 266 | age = la.Axis('age=0..115')
|
|
0 commit comments