NeXpy 2.0.0b4__tar.gz → 2.0.0b5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/PKG-INFO +1 -1
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/pyproject.toml +0 -1
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/NeXpy.egg-info/PKG-INFO +1 -1
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/NeXpy.egg-info/SOURCES.txt +4 -9
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/_version.py +2 -2
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/consoleapp.py +24 -33
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/dialogs.py +11 -4
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/fitdialogs.py +13 -28
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/mainwindow.py +50 -44
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/scripteditor.py +6 -3
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/utils.py +97 -38
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/readers/readspec.py +6 -7
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/tests/test_imports.py +0 -7
- nexpy-2.0.0b4/src/nexpy/api/frills/__init__.py +0 -0
- nexpy-2.0.0b4/src/nexpy/api/frills/fit.py +0 -239
- nexpy-2.0.0b4/src/nexpy/api/frills/models/__init__.py +0 -0
- nexpy-2.0.0b4/src/nexpy/gui/__init__.py +0 -0
- nexpy-2.0.0b4/src/nexpy/readers/__init__.py +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/.gitattributes +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/.github/dependabot.yaml +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/.github/workflows/ci.yml +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/.gitignore +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/COPYING +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/README.md +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/README.rst +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/conda-recipe/bld.bat +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/conda-recipe/build.sh +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/conda-recipe/meta.yaml +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/Makefile +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/make.bat +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/_static/__ignore__.txt +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/conf.py +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/examples.rst +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/favicon.ico +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/images/axis-limits-bar.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/images/customize-panel.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/images/limits-panel.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/images/nexpy-fits.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/images/nexpy-gui.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/images/nexpy-logo.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/images/options-tab.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/images/projection-panel.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/images/projection-tab.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/images/scan-panel.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/images/signal-tab.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/images/simple-plot.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/images/skewed-axis.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/images/x-tab.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/images/y-tab.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/images/z-tab.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/images/z-toolbar.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/includeme.rst +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/index.rst +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/pythongui.rst +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/pythonshell.rst +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/readers.rst +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/doc/source/treeapi.rst +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/setup.cfg +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/NeXpy.egg-info/dependency_links.txt +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/NeXpy.egg-info/entry_points.txt +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/NeXpy.egg-info/pbr.json +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/NeXpy.egg-info/requires.txt +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/NeXpy.egg-info/top_level.txt +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/__init__.py +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/examples/README.rst +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/examples/chopper.nxs +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/examples/example.nxs +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/examples/plugins/README.rst +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/examples/plugins/chopper_plugin/chopper/__init__.py +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/examples/plugins/chopper_plugin/chopper/__init__.pyc +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/examples/plugins/chopper_plugin/chopper/convert_qe.py +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/examples/plugins/chopper_plugin/chopper/convert_qe.pyc +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/examples/plugins/chopper_plugin/chopper/get_ei.py +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/examples/plugins/chopper_plugin/chopper/get_ei.pyc +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/examples/plugins/chopper_plugin/pyproject.toml +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/examples/scripts/README.rst +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/examples/scripts/chopper_plot.py +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/examples/scripts/example.py +0 -0
- {nexpy-2.0.0b4/src/nexpy/api → nexpy-2.0.0b5/src/nexpy/gui}/__init__.py +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/datadialogs.py +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/importdialog.py +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/plotview.py +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/pyqt.py +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/NeXpy.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/NeXpy.svg +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/back.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/backward-icon.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/customize.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/equal.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/export-data.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/export-figure.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/filesave.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/forward-icon.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/forward.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/hand.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/home.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/link-icon.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/lock-icon.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/lock-red-icon.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/modify-style.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/move.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/pause-icon.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/refresh-icon.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/unlock-icon.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/unlock-red-icon.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/resources/zoom_to_rect.png +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/treeview.py +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/gui/widgets.py +0 -0
- {nexpy-2.0.0b4/src/nexpy/api/frills → nexpy-2.0.0b5/src/nexpy}/models/bose.py +0 -0
- {nexpy-2.0.0b4/src/nexpy/api/frills → nexpy-2.0.0b5/src/nexpy}/models/critexp.py +0 -0
- {nexpy-2.0.0b4/src/nexpy/api/frills → nexpy-2.0.0b5/src/nexpy}/models/op.py +0 -0
- {nexpy-2.0.0b4/src/nexpy/api/frills → nexpy-2.0.0b5/src/nexpy}/models/pdfdecay.py +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/nexpygui.py +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/readers/readnpy.py +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/readers/readstack.py +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/readers/readtiff.py +0 -0
- {nexpy-2.0.0b4 → nexpy-2.0.0b5}/src/nexpy/readers/readtxt.py +0 -0
|
@@ -48,14 +48,6 @@ src/NeXpy.egg-info/top_level.txt
|
|
|
48
48
|
src/nexpy/__init__.py
|
|
49
49
|
src/nexpy/_version.py
|
|
50
50
|
src/nexpy/nexpygui.py
|
|
51
|
-
src/nexpy/api/__init__.py
|
|
52
|
-
src/nexpy/api/frills/__init__.py
|
|
53
|
-
src/nexpy/api/frills/fit.py
|
|
54
|
-
src/nexpy/api/frills/models/__init__.py
|
|
55
|
-
src/nexpy/api/frills/models/bose.py
|
|
56
|
-
src/nexpy/api/frills/models/critexp.py
|
|
57
|
-
src/nexpy/api/frills/models/op.py
|
|
58
|
-
src/nexpy/api/frills/models/pdfdecay.py
|
|
59
51
|
src/nexpy/examples/README.rst
|
|
60
52
|
src/nexpy/examples/chopper.nxs
|
|
61
53
|
src/nexpy/examples/example.nxs
|
|
@@ -106,7 +98,10 @@ src/nexpy/gui/resources/refresh-icon.png
|
|
|
106
98
|
src/nexpy/gui/resources/unlock-icon.png
|
|
107
99
|
src/nexpy/gui/resources/unlock-red-icon.png
|
|
108
100
|
src/nexpy/gui/resources/zoom_to_rect.png
|
|
109
|
-
src/nexpy/
|
|
101
|
+
src/nexpy/models/bose.py
|
|
102
|
+
src/nexpy/models/critexp.py
|
|
103
|
+
src/nexpy/models/op.py
|
|
104
|
+
src/nexpy/models/pdfdecay.py
|
|
110
105
|
src/nexpy/readers/readnpy.py
|
|
111
106
|
src/nexpy/readers/readspec.py
|
|
112
107
|
src/nexpy/readers/readstack.py
|
|
@@ -17,5 +17,5 @@ __version__: str
|
|
|
17
17
|
__version_tuple__: VERSION_TUPLE
|
|
18
18
|
version_tuple: VERSION_TUPLE
|
|
19
19
|
|
|
20
|
-
__version__ = version = '2.0.
|
|
21
|
-
__version_tuple__ = version_tuple = (2, 0, 0, '
|
|
20
|
+
__version__ = version = '2.0.0b5'
|
|
21
|
+
__version_tuple__ = version_tuple = (2, 0, 0, 'b5')
|
|
@@ -33,10 +33,7 @@ from .utils import (NXConfigParser, NXGarbageCollector, NXLogger, define_mode,
|
|
|
33
33
|
resource_icon, timestamp_age)
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
_tree = None
|
|
37
|
-
_shell = None
|
|
38
36
|
_mainwindow = None
|
|
39
|
-
_nexpy_dir = None
|
|
40
37
|
|
|
41
38
|
|
|
42
39
|
class NXConsoleApp(JupyterQtConsoleApp):
|
|
@@ -58,15 +55,14 @@ class NXConsoleApp(JupyterQtConsoleApp):
|
|
|
58
55
|
else:
|
|
59
56
|
nexpy_dir.mkdir(exist_ok=True)
|
|
60
57
|
for subdirectory in ['backups', 'models', 'plugins', 'readers',
|
|
61
|
-
'
|
|
58
|
+
'scripts']:
|
|
62
59
|
directory = nexpy_dir / subdirectory
|
|
63
60
|
directory.mkdir(exist_ok=True)
|
|
64
|
-
|
|
65
|
-
self.nexpy_dir = _nexpy_dir = nexpy_dir
|
|
61
|
+
self.nexpy_dir = nexpy_dir
|
|
66
62
|
self.backup_dir = self.nexpy_dir / 'backups'
|
|
63
|
+
self.model_dir = self.nexpy_dir / 'models'
|
|
67
64
|
self.plugin_dir = self.nexpy_dir / 'plugins'
|
|
68
65
|
self.reader_dir = self.nexpy_dir / 'readers'
|
|
69
|
-
self.writer_dir = self.nexpy_dir / 'writers'
|
|
70
66
|
self.script_dir = self.nexpy_dir / 'scripts'
|
|
71
67
|
self.scratch_file = self.nexpy_dir / 'w0.nxs'
|
|
72
68
|
if not self.scratch_file.exists():
|
|
@@ -149,31 +145,33 @@ class NXConsoleApp(JupyterQtConsoleApp):
|
|
|
149
145
|
sys.stdout = sys.stderr = NXLogger()
|
|
150
146
|
|
|
151
147
|
def init_plugins(self):
|
|
152
|
-
"""
|
|
148
|
+
"""
|
|
149
|
+
Initialize plugins.
|
|
150
|
+
|
|
151
|
+
This method looks for plugins stored as files in the NeXpy
|
|
152
|
+
directory or registered as entry points, and adds them to the
|
|
153
|
+
list of plugins in the NeXpy settings file. These will be added
|
|
154
|
+
as additional menu items if enabled by the Manage Plugins
|
|
155
|
+
dialog.
|
|
156
|
+
"""
|
|
153
157
|
eps = entry_points()
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
plugin = str(path)
|
|
161
|
-
if plugin not in plugins:
|
|
162
|
-
self.settings.set(plugin_group, plugin, value=None)
|
|
163
|
-
group_name = 'nexpy.' + plugin_group
|
|
164
|
-
for entry in eps.select(group=group_name):
|
|
165
|
-
plugin = entry.module
|
|
158
|
+
plugin = None
|
|
159
|
+
plugins = self.settings.options('plugins')
|
|
160
|
+
for path in self.plugin_dir.iterdir():
|
|
161
|
+
if (path.is_dir() and not (path.name.startswith('_') or
|
|
162
|
+
path.name.startswith('.'))):
|
|
163
|
+
plugin = str(path)
|
|
166
164
|
if plugin not in plugins:
|
|
167
|
-
self.settings.set(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
165
|
+
self.settings.set('plugins', plugin, value=None)
|
|
166
|
+
group_name = 'nexpy.plugins'
|
|
167
|
+
for entry in eps.select(group=group_name):
|
|
168
|
+
plugin = entry.module
|
|
169
|
+
if plugin not in plugins:
|
|
170
|
+
self.settings.set('plugins', plugin, value=None)
|
|
171
171
|
|
|
172
172
|
def init_tree(self):
|
|
173
173
|
"""Initialize the root element of the NeXpy tree view."""
|
|
174
|
-
global _tree
|
|
175
174
|
self.tree = NXtree()
|
|
176
|
-
_tree = self.tree
|
|
177
175
|
|
|
178
176
|
def init_config(self):
|
|
179
177
|
"""Initialize the configuration options for the NeXpy console."""
|
|
@@ -216,8 +214,6 @@ class NXConsoleApp(JupyterQtConsoleApp):
|
|
|
216
214
|
|
|
217
215
|
def init_shell(self, args):
|
|
218
216
|
"""Initialize imports in the shell."""
|
|
219
|
-
global _shell
|
|
220
|
-
_shell = self.window.user_ns
|
|
221
217
|
s = ("import nexusformat.nexus as nx\n"
|
|
222
218
|
"from nexusformat.nexus import NXgroup, NXfield, NXattr, NXlink\n"
|
|
223
219
|
"from nexusformat.nexus import *\n"
|
|
@@ -323,11 +319,6 @@ class NXConsoleApp(JupyterQtConsoleApp):
|
|
|
323
319
|
self.app.exec()
|
|
324
320
|
|
|
325
321
|
|
|
326
|
-
# -----------------------------------------------------------------------------
|
|
327
|
-
# Main entry point
|
|
328
|
-
# -----------------------------------------------------------------------------
|
|
329
|
-
|
|
330
|
-
|
|
331
322
|
def main(args):
|
|
332
323
|
"""
|
|
333
324
|
Main entry point for NeXpy console application.
|
|
@@ -1116,6 +1116,10 @@ class SettingsDialog(NXDialog):
|
|
|
1116
1116
|
self.parameters.add('lockexpiry', cfg['lockexpiry'], 'Lock Expiry (s)')
|
|
1117
1117
|
self.parameters.add('lockdirectory', cfg['lockdirectory'],
|
|
1118
1118
|
'Lock Directory')
|
|
1119
|
+
self.parameters.add('scriptdirectory',
|
|
1120
|
+
self.mainwindow.settings.get('settings',
|
|
1121
|
+
'scriptdirectory'),
|
|
1122
|
+
'Script Directory')
|
|
1119
1123
|
self.parameters.add('definitions', cfg['definitions'],
|
|
1120
1124
|
'NeXus Definitions Directory')
|
|
1121
1125
|
self.parameters.add('recursive', ['True', 'False'], 'File Recursion')
|
|
@@ -1154,6 +1158,8 @@ class SettingsDialog(NXDialog):
|
|
|
1154
1158
|
cfg['lockexpiry'])
|
|
1155
1159
|
self.mainwindow.settings.set('settings', 'lockdirectory',
|
|
1156
1160
|
cfg['lockdirectory'])
|
|
1161
|
+
self.mainwindow.settings.set('settings', 'scriptdirectory',
|
|
1162
|
+
self.parameters['scriptdirectory'].value)
|
|
1157
1163
|
self.mainwindow.settings.set('settings', 'definitions',
|
|
1158
1164
|
cfg['definitions'])
|
|
1159
1165
|
self.mainwindow.settings.set('settings', 'recursive',
|
|
@@ -4615,9 +4621,9 @@ class FieldDialog(NXDialog):
|
|
|
4615
4621
|
if dtype == "char":
|
|
4616
4622
|
return value
|
|
4617
4623
|
else:
|
|
4618
|
-
from .consoleapp import _shell
|
|
4619
4624
|
try:
|
|
4620
|
-
return eval(value, {"__builtins__": {}},
|
|
4625
|
+
return eval(value, {"__builtins__": {}},
|
|
4626
|
+
self.mainwindow.user_ns)
|
|
4621
4627
|
except Exception:
|
|
4622
4628
|
return value
|
|
4623
4629
|
else:
|
|
@@ -4791,9 +4797,9 @@ class AttributeDialog(NXDialog):
|
|
|
4791
4797
|
if dtype == "char":
|
|
4792
4798
|
return value
|
|
4793
4799
|
else:
|
|
4794
|
-
from .consoleapp import _shell
|
|
4795
4800
|
try:
|
|
4796
|
-
return eval(value, {"__builtins__": {}},
|
|
4801
|
+
return eval(value, {"__builtins__": {}},
|
|
4802
|
+
self.mainwindow.user_ns)
|
|
4797
4803
|
except Exception:
|
|
4798
4804
|
return value
|
|
4799
4805
|
else:
|
|
@@ -5650,6 +5656,7 @@ class ManagePluginsDialog(NXDialog):
|
|
|
5650
5656
|
name, actions = p['menu'], p['actions']
|
|
5651
5657
|
self.mainwindow.add_plugin_menu(
|
|
5652
5658
|
name, actions, before=self.mainwindow.view_menu)
|
|
5659
|
+
self.mainwindow.plugins[plugin] = p
|
|
5653
5660
|
for plugin in self.plugins:
|
|
5654
5661
|
self.settings.set('plugins', plugin,
|
|
5655
5662
|
self.plugins[plugin]['order'])
|
|
@@ -7,11 +7,8 @@
|
|
|
7
7
|
# -----------------------------------------------------------------------------
|
|
8
8
|
import inspect
|
|
9
9
|
import re
|
|
10
|
-
import sys
|
|
11
10
|
import types
|
|
12
|
-
from importlib import import_module
|
|
13
11
|
from itertools import cycle
|
|
14
|
-
from pathlib import Path
|
|
15
12
|
|
|
16
13
|
import numpy as np
|
|
17
14
|
from lmfit import Model, Parameters
|
|
@@ -21,7 +18,7 @@ from nexusformat.nexus import (NeXusError, NXdata, NXentry, NXfield, NXnote,
|
|
|
21
18
|
|
|
22
19
|
from .plotview import NXPlotView, linestyles
|
|
23
20
|
from .pyqt import QtCore, QtWidgets
|
|
24
|
-
from .utils import display_message, format_float,
|
|
21
|
+
from .utils import display_message, format_float, load_models, report_error
|
|
25
22
|
from .widgets import (NXCheckBox, NXColorBox, NXComboBox, NXDialog, NXLabel,
|
|
26
23
|
NXLineEdit, NXMessageBox, NXPanel, NXPushButton,
|
|
27
24
|
NXrectangle, NXScrollArea, NXTab)
|
|
@@ -33,10 +30,11 @@ def get_models():
|
|
|
33
30
|
|
|
34
31
|
This function returns a dictionary of LMFIT models, including those
|
|
35
32
|
defined in the LMFIT package and those defined in the
|
|
36
|
-
``nexpy.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
``nexpy.models`` package. Additional models can also be defined in
|
|
34
|
+
the ``~/.nexpy/models`` directory or in another installed package,
|
|
35
|
+
which declares the entry point ``nexpy.models``. The models are
|
|
36
|
+
returned as a dictionary where the keys are the names of the models
|
|
37
|
+
and the values are the classes defining the models.
|
|
40
38
|
"""
|
|
41
39
|
from lmfit.models import lmfit_models
|
|
42
40
|
models = lmfit_models
|
|
@@ -45,28 +43,15 @@ def get_models():
|
|
|
45
43
|
if 'Gaussian-2D' in models:
|
|
46
44
|
del models['Gaussian-2D']
|
|
47
45
|
|
|
48
|
-
|
|
46
|
+
nexpy_models = load_models()
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
sys.path.append(str(models_path))
|
|
52
|
-
for f in models_path.glob("*.py"):
|
|
53
|
-
if f.stem != '__init__':
|
|
54
|
-
filenames.add(f.stem)
|
|
55
|
-
|
|
56
|
-
private_path = Path.home() / '.nexpy' / 'models'
|
|
57
|
-
if private_path.is_dir():
|
|
58
|
-
sys.path.append(str(private_path))
|
|
59
|
-
for f in private_path.glob('*.py'):
|
|
60
|
-
if f.stem != '__init__':
|
|
61
|
-
filenames.add(f.stem)
|
|
62
|
-
|
|
63
|
-
for name in sorted(filenames):
|
|
48
|
+
for model in nexpy_models:
|
|
64
49
|
try:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
50
|
+
models.update(
|
|
51
|
+
dict((n.strip('Model'), m)
|
|
52
|
+
for n, m in inspect.getmembers(nexpy_models[model],
|
|
53
|
+
inspect.isclass)
|
|
54
|
+
if issubclass(m, Model) and n != 'Model'))
|
|
70
55
|
except ImportError:
|
|
71
56
|
pass
|
|
72
57
|
|
|
@@ -13,9 +13,6 @@ plot the data, and a Jupyter console to execute Python commands. The
|
|
|
13
13
|
namespace of the console includes the NeXus data loaded into the tree.
|
|
14
14
|
"""
|
|
15
15
|
|
|
16
|
-
# -----------------------------------------------------------------------------
|
|
17
|
-
# Imports
|
|
18
|
-
# -----------------------------------------------------------------------------
|
|
19
16
|
import logging
|
|
20
17
|
import sys
|
|
21
18
|
import webbrowser
|
|
@@ -37,14 +34,13 @@ from .dialogs import (AttributeDialog, CustomizeDialog, DirectoryDialog,
|
|
|
37
34
|
PlotScalarDialog, ProjectionDialog, RenameDialog,
|
|
38
35
|
ScanDialog, SettingsDialog, SignalDialog, UnlockDialog,
|
|
39
36
|
ValidateDialog, ViewDialog)
|
|
40
|
-
from .fitdialogs import FitDialog
|
|
41
37
|
from .plotview import NXPlotView
|
|
42
38
|
from .pyqt import QtCore, QtGui, QtWidgets, getOpenFileName, getSaveFileName
|
|
43
39
|
from .scripteditor import NXScriptWindow
|
|
44
40
|
from .treeview import NXTreeView
|
|
45
41
|
from .utils import (confirm_action, define_mode, display_message, get_colors,
|
|
46
|
-
get_name,
|
|
47
|
-
|
|
42
|
+
get_name, is_file_locked, load_image, load_plugin,
|
|
43
|
+
load_readers, natural_sort, package_files, report_error,
|
|
48
44
|
timestamp)
|
|
49
45
|
|
|
50
46
|
|
|
@@ -105,6 +101,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
105
101
|
|
|
106
102
|
self.dialogs = []
|
|
107
103
|
self.panels = {}
|
|
104
|
+
self.scripts = {}
|
|
108
105
|
self.log_window = None
|
|
109
106
|
self.copied_node = None
|
|
110
107
|
self._memroot = None
|
|
@@ -114,7 +111,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
114
111
|
self.backup_dir = self.app.backup_dir
|
|
115
112
|
self.plugin_dir = self.app.plugin_dir
|
|
116
113
|
self.reader_dir = self.app.reader_dir
|
|
117
|
-
self.
|
|
114
|
+
self.model_dir = self.app.model_dir
|
|
118
115
|
self.script_dir = self.app.script_dir
|
|
119
116
|
self.scratch_file = self.app.scratch_file
|
|
120
117
|
self.settings_file = self.app.settings_file
|
|
@@ -186,7 +183,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
186
183
|
self.user_ns['plotview'] = self.plotview
|
|
187
184
|
self.user_ns['plotviews'] = self.plotviews = self.plotview.plotviews
|
|
188
185
|
self.user_ns['treeview'] = self.treeview
|
|
189
|
-
self.user_ns['nxtree'] = self.
|
|
186
|
+
self.user_ns['nxtree'] = self.tree
|
|
190
187
|
self.user_ns['mainwindow'] = self
|
|
191
188
|
|
|
192
189
|
self.nxclasses = get_base_classes()
|
|
@@ -831,8 +828,20 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
831
828
|
|
|
832
829
|
self.script_menu.addSeparator()
|
|
833
830
|
|
|
834
|
-
self.
|
|
835
|
-
|
|
831
|
+
if self.settings.has_option('settings', 'scriptdirectory'):
|
|
832
|
+
self.public_script_dir = self.settings.get('settings',
|
|
833
|
+
'scriptdirectory')
|
|
834
|
+
|
|
835
|
+
self.public_script_menu = QtWidgets.QMenu('Public Scripts', self)
|
|
836
|
+
self.script_menu.addMenu(self.public_script_menu)
|
|
837
|
+
self.add_script_directory(self.public_script_dir,
|
|
838
|
+
self.public_script_menu)
|
|
839
|
+
|
|
840
|
+
self.script_menu.addSeparator()
|
|
841
|
+
|
|
842
|
+
self.private_script_menu = QtWidgets.QMenu('Private Scripts', self)
|
|
843
|
+
self.script_menu.addMenu(self.private_script_menu)
|
|
844
|
+
self.add_script_directory(self.script_dir, self.private_script_menu)
|
|
836
845
|
|
|
837
846
|
def init_help_menu(self):
|
|
838
847
|
"""Initialize the Help menu."""
|
|
@@ -920,31 +929,20 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
920
929
|
|
|
921
930
|
def init_import_menu(self):
|
|
922
931
|
"""Add an import menu item for every module in the readers directory"""
|
|
923
|
-
import_files = {}
|
|
924
932
|
self.import_menu = QtWidgets.QMenu("Import", self)
|
|
925
933
|
self.file_menu.addMenu(self.import_menu)
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
if f.stem != '__init__':
|
|
930
|
-
import_files[f.stem] = private_path.joinpath(f.name)
|
|
931
|
-
public_path = package_files('nexpy').joinpath('readers')
|
|
932
|
-
for f in public_path.glob('*.py'):
|
|
933
|
-
if f.stem != '__init__':
|
|
934
|
-
import_files[f.stem] = public_path.joinpath(f.name)
|
|
935
|
-
self.importer = {}
|
|
936
|
-
for import_name in sorted(import_files):
|
|
934
|
+
readers = load_readers()
|
|
935
|
+
self.readers = {}
|
|
936
|
+
for reader in readers:
|
|
937
937
|
try:
|
|
938
|
-
import_module = import_plugin(import_name,
|
|
939
|
-
import_files[import_name])
|
|
940
938
|
import_action = QtWidgets.QAction(
|
|
941
|
-
"Import "+
|
|
939
|
+
"Import "+readers[reader].filetype, self,
|
|
942
940
|
triggered=self.show_import_dialog)
|
|
943
941
|
self.add_menu_action(self.import_menu, import_action, self)
|
|
944
|
-
self.
|
|
942
|
+
self.readers[import_action] = readers[reader]
|
|
945
943
|
except Exception as error:
|
|
946
944
|
logging.warning(
|
|
947
|
-
f'The "{
|
|
945
|
+
f'The "{reader}" importer could not be added '
|
|
948
946
|
'to the Import menu\n' + 36*' ' + f'Error: {error}')
|
|
949
947
|
|
|
950
948
|
def new_workspace(self):
|
|
@@ -1269,7 +1267,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
1269
1267
|
def show_import_dialog(self):
|
|
1270
1268
|
"""Show the import dialog."""
|
|
1271
1269
|
try:
|
|
1272
|
-
import_module = self.
|
|
1270
|
+
import_module = self.readers[self.sender()]
|
|
1273
1271
|
self.import_dialog = import_module.ImportDialog(parent=self)
|
|
1274
1272
|
self.import_dialog.show()
|
|
1275
1273
|
except NeXusError as error:
|
|
@@ -1703,7 +1701,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
1703
1701
|
elif node.nxfilemode == 'r':
|
|
1704
1702
|
raise NeXusError("NeXus file is locked")
|
|
1705
1703
|
dialog = GroupDialog(node, parent=self)
|
|
1706
|
-
dialog.
|
|
1704
|
+
dialog.show()
|
|
1707
1705
|
except NeXusError as error:
|
|
1708
1706
|
report_error("Adding Group", error)
|
|
1709
1707
|
|
|
@@ -1717,7 +1715,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
1717
1715
|
elif node.nxfilemode == 'r':
|
|
1718
1716
|
raise NeXusError("NeXus file is locked")
|
|
1719
1717
|
dialog = FieldDialog(node, parent=self)
|
|
1720
|
-
dialog.
|
|
1718
|
+
dialog.show()
|
|
1721
1719
|
except NeXusError as error:
|
|
1722
1720
|
report_error("Adding Field", error)
|
|
1723
1721
|
|
|
@@ -1731,7 +1729,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
1731
1729
|
elif node.nxfilemode == 'r':
|
|
1732
1730
|
raise NeXusError("NeXus file is locked")
|
|
1733
1731
|
dialog = AttributeDialog(node, parent=self)
|
|
1734
|
-
dialog.
|
|
1732
|
+
dialog.show()
|
|
1735
1733
|
except NeXusError as error:
|
|
1736
1734
|
report_error("Adding Attribute", error)
|
|
1737
1735
|
|
|
@@ -1752,7 +1750,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
1752
1750
|
node.nxgroup.nxfilemode != 'r'):
|
|
1753
1751
|
path = node.nxpath
|
|
1754
1752
|
dialog = RenameDialog(node, parent=self)
|
|
1755
|
-
dialog.
|
|
1753
|
+
dialog.show()
|
|
1756
1754
|
logging.info(f"'{path}' renamed as '{node.nxpath}'")
|
|
1757
1755
|
else:
|
|
1758
1756
|
raise NeXusError("NeXus file is locked")
|
|
@@ -2052,6 +2050,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
2052
2050
|
--------
|
|
2053
2051
|
:ref:`Fitting NeXus Data`_.
|
|
2054
2052
|
"""
|
|
2053
|
+
from .fitdialogs import FitDialog
|
|
2055
2054
|
try:
|
|
2056
2055
|
node = self.treeview.get_node()
|
|
2057
2056
|
if node is None:
|
|
@@ -2094,6 +2093,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
2094
2093
|
--------
|
|
2095
2094
|
:ref:`Fitting NeXus Data`_.
|
|
2096
2095
|
"""
|
|
2096
|
+
from .fitdialogs import FitDialog
|
|
2097
2097
|
try:
|
|
2098
2098
|
node = self.treeview.get_node()
|
|
2099
2099
|
if node is None:
|
|
@@ -2445,15 +2445,27 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
2445
2445
|
menu : QMenu
|
|
2446
2446
|
The menu to add the actions to.
|
|
2447
2447
|
"""
|
|
2448
|
+
if directory is None or not Path(directory).is_dir():
|
|
2449
|
+
menu.setEnabled(False)
|
|
2450
|
+
return
|
|
2451
|
+
directory = Path(directory)
|
|
2448
2452
|
names = sorted(path.name for path in directory.iterdir())
|
|
2453
|
+
empty_directory = True
|
|
2449
2454
|
for name in names:
|
|
2450
2455
|
item_path = directory / name
|
|
2456
|
+
if name.startswith('.') or name.startswith('_'):
|
|
2457
|
+
continue
|
|
2451
2458
|
if item_path.is_dir():
|
|
2452
2459
|
submenu = QtWidgets.QMenu(name, self)
|
|
2453
2460
|
menu.addMenu(submenu)
|
|
2454
2461
|
self.add_script_directory(item_path, submenu)
|
|
2455
2462
|
elif item_path.suffix == '.py':
|
|
2456
2463
|
self.add_script_action(item_path, menu)
|
|
2464
|
+
empty_directory = False
|
|
2465
|
+
if empty_directory:
|
|
2466
|
+
menu.setEnabled(False)
|
|
2467
|
+
else:
|
|
2468
|
+
menu.setEnabled(True)
|
|
2457
2469
|
|
|
2458
2470
|
def add_script_action(self, file_name, menu):
|
|
2459
2471
|
"""
|
|
@@ -2472,18 +2484,12 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
2472
2484
|
self.add_menu_action(menu, script_action, self)
|
|
2473
2485
|
self.scripts[script_action] = (menu, str(file_name))
|
|
2474
2486
|
|
|
2475
|
-
def
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
file_name : Path
|
|
2482
|
-
The path to the Python script.
|
|
2483
|
-
"""
|
|
2484
|
-
for action, (menu, name) in self.scripts.items():
|
|
2485
|
-
if name == str(file_name):
|
|
2486
|
-
menu.removeAction(action)
|
|
2487
|
+
def refresh_script_menus(self):
|
|
2488
|
+
self.public_script_menu.clear()
|
|
2489
|
+
self.add_script_directory(self.public_script_dir,
|
|
2490
|
+
self.public_script_menu)
|
|
2491
|
+
self.private_script_menu.clear()
|
|
2492
|
+
self.add_script_directory(self.script_dir, self.private_script_menu)
|
|
2487
2493
|
|
|
2488
2494
|
def _open_nexpy_online_help(self):
|
|
2489
2495
|
"""Open the NeXpy online help in a web browser."""
|
|
@@ -192,13 +192,16 @@ class NXScriptWindow(NXPanel):
|
|
|
192
192
|
"""
|
|
193
193
|
if file_name:
|
|
194
194
|
label = Path(file_name).name
|
|
195
|
+
tooltip = file_name
|
|
195
196
|
else:
|
|
196
197
|
label = f'Untitled {self.count+1}'
|
|
198
|
+
tooltip = label
|
|
197
199
|
super().activate(label, file_name)
|
|
198
200
|
if file_name:
|
|
199
201
|
self.tab.default_directory = Path(file_name).parent
|
|
200
202
|
else:
|
|
201
203
|
self.tab.default_directory = self.mainwindow.script_dir
|
|
204
|
+
self.tabwidget.setTabToolTip(self.tab.index, tooltip)
|
|
202
205
|
|
|
203
206
|
|
|
204
207
|
class NXScriptEditor(NXTab):
|
|
@@ -361,8 +364,8 @@ class NXScriptEditor(NXTab):
|
|
|
361
364
|
f.write(self.get_text())
|
|
362
365
|
self.file_name = file_name
|
|
363
366
|
self.tab_label = Path(self.file_name).name
|
|
364
|
-
self.
|
|
365
|
-
|
|
367
|
+
self.panel.tabwidget.setTabToolTip(self.index, file_name)
|
|
368
|
+
self.mainwindow.refresh_script_menus()
|
|
366
369
|
self.delete_button.setVisible(True)
|
|
367
370
|
|
|
368
371
|
def reload_script(self):
|
|
@@ -395,5 +398,5 @@ class NXScriptEditor(NXTab):
|
|
|
395
398
|
f"Are you sure you want to delete '{self.file_name}'?",
|
|
396
399
|
"This cannot be reversed"):
|
|
397
400
|
Path(self.file_name).unlink()
|
|
398
|
-
self.mainwindow.
|
|
401
|
+
self.mainwindow.refresh_script_menus()
|
|
399
402
|
self.panel.close()
|