pymodaq 3.6.12__py3-none-any.whl → 4.0.1__py3-none-any.whl
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.
Potentially problematic release.
This version of pymodaq might be problematic. Click here for more details.
- pymodaq/__init__.py +13 -6
- pymodaq/control_modules/__init__.py +0 -7
- pymodaq/control_modules/daq_move.py +965 -2
- pymodaq/control_modules/daq_move_ui.py +319 -0
- pymodaq/control_modules/daq_viewer.py +1573 -3
- pymodaq/control_modules/daq_viewer_ui.py +393 -0
- pymodaq/control_modules/mocks.py +51 -0
- pymodaq/control_modules/move_utility_classes.py +709 -8
- pymodaq/control_modules/utils.py +256 -0
- pymodaq/control_modules/viewer_utility_classes.py +663 -6
- pymodaq/daq_utils.py +89 -0
- pymodaq/dashboard.py +91 -72
- pymodaq/examples/custom_app.py +12 -11
- pymodaq/examples/custom_viewer.py +10 -10
- pymodaq/examples/function_plotter.py +16 -13
- pymodaq/examples/nonlinearscanner.py +8 -6
- pymodaq/examples/parameter_ex.py +7 -7
- pymodaq/examples/preset_MockCamera.xml +1 -0
- pymodaq/extensions/__init__.py +16 -0
- pymodaq/extensions/console.py +76 -0
- pymodaq/{daq_logger.py → extensions/daq_logger.py} +115 -65
- pymodaq/extensions/daq_scan.py +1339 -0
- pymodaq/extensions/daq_scan_ui.py +240 -0
- pymodaq/extensions/h5browser.py +23 -0
- pymodaq/{pid → extensions/pid}/__init__.py +4 -2
- pymodaq/{pid → extensions/pid}/daq_move_PID.py +2 -2
- pymodaq/{pid → extensions/pid}/pid_controller.py +48 -36
- pymodaq/{pid → extensions/pid}/utils.py +52 -6
- pymodaq/extensions/utils.py +40 -0
- pymodaq/post_treatment/__init__.py +6 -0
- pymodaq/{daq_analysis → post_treatment/daq_analysis}/daq_analysis_main.py +17 -17
- pymodaq/{daq_measurement → post_treatment/daq_measurement}/daq_measurement_main.py +8 -14
- pymodaq/post_treatment/load_and_plot.py +219 -0
- pymodaq/post_treatment/process_to_scalar.py +263 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/run_all.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop_all.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.bat +1 -1
- pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.qrc +1 -0
- pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources_rc.py +109784 -109173
- pymodaq/resources/QtDesigner_Ressources/icons.svg +142 -0
- pymodaq/resources/VERSION +1 -1
- pymodaq/resources/config_template.toml +32 -13
- pymodaq/resources/preset_default.xml +1 -1
- pymodaq/{daq_utils → utils}/Tuto innosetup/script_full_setup.iss +1 -1
- pymodaq/utils/__init__.py +0 -29
- pymodaq/utils/abstract/__init__.py +48 -0
- pymodaq/{daq_utils → utils}/abstract/logger.py +7 -3
- pymodaq/utils/array_manipulation.py +379 -8
- pymodaq/{daq_utils → utils}/calibration_camera.py +6 -6
- pymodaq/{daq_utils → utils}/chrono_timer.py +1 -1
- pymodaq/utils/config.py +448 -0
- pymodaq/utils/conftests.py +5 -0
- pymodaq/utils/daq_utils.py +828 -8
- pymodaq/utils/data.py +1873 -7
- pymodaq/{daq_utils → utils}/db/db_logger/db_logger.py +86 -47
- pymodaq/{daq_utils → utils}/db/db_logger/db_logger_models.py +31 -10
- pymodaq/{daq_utils → utils}/enums.py +12 -7
- pymodaq/utils/exceptions.py +37 -0
- pymodaq/utils/factory.py +82 -0
- pymodaq/{daq_utils → utils}/gui_utils/__init__.py +1 -1
- pymodaq/utils/gui_utils/custom_app.py +129 -0
- pymodaq/utils/gui_utils/file_io.py +66 -0
- pymodaq/{daq_utils → utils}/gui_utils/layout.py +2 -2
- pymodaq/{daq_utils → utils}/gui_utils/utils.py +13 -3
- pymodaq/{daq_utils → utils}/gui_utils/widgets/__init__.py +2 -2
- pymodaq/utils/gui_utils/widgets/label.py +24 -0
- pymodaq/{daq_utils → utils}/gui_utils/widgets/lcd.py +12 -7
- pymodaq/{daq_utils → utils}/gui_utils/widgets/push.py +66 -2
- pymodaq/{daq_utils → utils}/gui_utils/widgets/qled.py +6 -4
- pymodaq/utils/gui_utils/widgets/spinbox.py +24 -0
- pymodaq/{daq_utils → utils}/gui_utils/widgets/table.py +2 -2
- pymodaq/utils/h5modules/__init__.py +1 -0
- pymodaq/{daq_utils/h5backend.py → utils/h5modules/backends.py} +200 -112
- pymodaq/utils/h5modules/browsing.py +683 -0
- pymodaq/utils/h5modules/data_saving.py +839 -0
- pymodaq/utils/h5modules/h5logging.py +110 -0
- pymodaq/utils/h5modules/module_saving.py +350 -0
- pymodaq/utils/h5modules/saving.py +914 -0
- pymodaq/utils/h5modules/utils.py +85 -0
- pymodaq/utils/logger.py +64 -6
- pymodaq/utils/managers/action_manager.py +460 -0
- pymodaq/{daq_utils → utils}/managers/batchscan_manager.py +144 -112
- pymodaq/{daq_utils → utils}/managers/modules_manager.py +188 -114
- pymodaq/{daq_utils → utils}/managers/overshoot_manager.py +3 -3
- pymodaq/utils/managers/parameter_manager.py +110 -0
- pymodaq/{daq_utils → utils}/managers/preset_manager.py +17 -13
- pymodaq/{daq_utils → utils}/managers/preset_manager_utils.py +8 -7
- pymodaq/{daq_utils → utils}/managers/remote_manager.py +7 -6
- pymodaq/{daq_utils → utils}/managers/roi_manager.py +148 -57
- pymodaq/utils/math_utils.py +546 -10
- pymodaq/{daq_utils → utils}/messenger.py +5 -1
- pymodaq/utils/parameter/__init__.py +2 -15
- pymodaq/{daq_utils → utils}/parameter/ioxml.py +12 -6
- pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/__init__.py +1 -3
- pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/filedir.py +1 -1
- pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/itemselect.py +3 -0
- pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/led.py +1 -1
- pymodaq/utils/parameter/pymodaq_ptypes/pixmap.py +161 -0
- pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/slide.py +1 -1
- pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/table.py +1 -1
- pymodaq/utils/parameter/utils.py +206 -11
- pymodaq/utils/plotting/data_viewers/__init__.py +6 -0
- pymodaq/utils/plotting/data_viewers/viewer.py +393 -0
- pymodaq/utils/plotting/data_viewers/viewer0D.py +251 -0
- pymodaq/utils/plotting/data_viewers/viewer1D.py +574 -0
- pymodaq/{daq_utils → utils}/plotting/data_viewers/viewer1Dbasic.py +8 -3
- pymodaq/{daq_utils → utils}/plotting/data_viewers/viewer2D.py +292 -357
- pymodaq/{daq_utils → utils}/plotting/data_viewers/viewer2D_basic.py +58 -75
- pymodaq/utils/plotting/data_viewers/viewerND.py +738 -0
- pymodaq/{daq_utils → utils}/plotting/gant_chart.py +2 -2
- pymodaq/{daq_utils → utils}/plotting/items/axis_scaled.py +4 -2
- pymodaq/{daq_utils → utils}/plotting/items/image.py +8 -6
- pymodaq/utils/plotting/navigator.py +355 -0
- pymodaq/utils/plotting/scan_selector.py +480 -0
- pymodaq/utils/plotting/utils/axes_viewer.py +88 -0
- pymodaq/utils/plotting/utils/filter.py +538 -0
- pymodaq/utils/plotting/utils/lineout.py +224 -0
- pymodaq/{daq_utils → utils}/plotting/utils/plot_utils.py +196 -84
- pymodaq/{daq_utils → utils}/plotting/utils/signalND.py +21 -13
- pymodaq/utils/plotting/widgets.py +76 -0
- pymodaq/utils/scanner/__init__.py +10 -0
- pymodaq/utils/scanner/scan_factory.py +204 -0
- pymodaq/utils/scanner/scanner.py +271 -0
- pymodaq/utils/scanner/scanners/_1d_scanners.py +117 -0
- pymodaq/utils/scanner/scanners/_2d_scanners.py +293 -0
- pymodaq/utils/scanner/scanners/sequential.py +192 -0
- pymodaq/utils/scanner/scanners/tabular.py +294 -0
- pymodaq/utils/scanner/utils.py +83 -0
- pymodaq/utils/slicing.py +47 -0
- pymodaq/utils/svg/__init__.py +6 -0
- pymodaq/utils/svg/svg_renderer.py +20 -0
- pymodaq/utils/svg/svg_view.py +35 -0
- pymodaq/utils/svg/svg_viewer2D.py +51 -0
- pymodaq/{daq_utils → utils}/tcp_server_client.py +36 -37
- pymodaq/{daq_utils → utils}/tree_layout/tree_layout_main.py +50 -35
- pymodaq/utils/units.py +216 -0
- pymodaq-4.0.1.dist-info/METADATA +159 -0
- {pymodaq-3.6.12.dist-info → pymodaq-4.0.1.dist-info}/RECORD +167 -170
- {pymodaq-3.6.12.dist-info → pymodaq-4.0.1.dist-info}/WHEEL +1 -2
- pymodaq-4.0.1.dist-info/entry_points.txt +8 -0
- pymodaq/daq_move/daq_move_gui.py +0 -279
- pymodaq/daq_move/daq_move_gui.ui +0 -534
- pymodaq/daq_move/daq_move_main.py +0 -1042
- pymodaq/daq_move/process_from_QtDesigner_DAQ_Move_GUI.bat +0 -2
- pymodaq/daq_move/utility_classes.py +0 -671
- pymodaq/daq_scan.py +0 -2160
- pymodaq/daq_utils/array_manipulation.py +0 -386
- pymodaq/daq_utils/config.py +0 -273
- pymodaq/daq_utils/conftests.py +0 -7
- pymodaq/daq_utils/custom_parameter_tree.py +0 -9
- pymodaq/daq_utils/daq_enums.py +0 -133
- pymodaq/daq_utils/daq_utils.py +0 -1402
- pymodaq/daq_utils/exceptions.py +0 -71
- pymodaq/daq_utils/gui_utils/custom_app.py +0 -103
- pymodaq/daq_utils/gui_utils/file_io.py +0 -75
- pymodaq/daq_utils/gui_utils/widgets/spinbox.py +0 -9
- pymodaq/daq_utils/h5exporter_hyperspy.py +0 -115
- pymodaq/daq_utils/h5exporters.py +0 -242
- pymodaq/daq_utils/h5modules.py +0 -1559
- pymodaq/daq_utils/h5utils.py +0 -241
- pymodaq/daq_utils/managers/action_manager.py +0 -236
- pymodaq/daq_utils/managers/parameter_manager.py +0 -57
- pymodaq/daq_utils/math_utils.py +0 -705
- pymodaq/daq_utils/parameter/__init__.py +0 -1
- pymodaq/daq_utils/parameter/oldpymodaq_ptypes.py +0 -1626
- pymodaq/daq_utils/parameter/pymodaq_ptypes/pixmap.py +0 -85
- pymodaq/daq_utils/parameter/utils.py +0 -136
- pymodaq/daq_utils/plotting/data_viewers/__init__.py +0 -0
- pymodaq/daq_utils/plotting/data_viewers/process_from_QtDesigner_0DViewer_GUI.bat +0 -2
- pymodaq/daq_utils/plotting/data_viewers/viewer0D.py +0 -204
- pymodaq/daq_utils/plotting/data_viewers/viewer0D_GUI.py +0 -89
- pymodaq/daq_utils/plotting/data_viewers/viewer0D_GUI.ui +0 -131
- pymodaq/daq_utils/plotting/data_viewers/viewer1D.py +0 -781
- pymodaq/daq_utils/plotting/data_viewers/viewerND.py +0 -894
- pymodaq/daq_utils/plotting/data_viewers/viewerbase.py +0 -64
- pymodaq/daq_utils/plotting/items/__init__.py +0 -0
- pymodaq/daq_utils/plotting/navigator.py +0 -500
- pymodaq/daq_utils/plotting/scan_selector.py +0 -289
- pymodaq/daq_utils/plotting/utils/__init__.py +0 -0
- pymodaq/daq_utils/plotting/utils/filter.py +0 -236
- pymodaq/daq_utils/plotting/viewer0D/__init__.py +0 -0
- pymodaq/daq_utils/plotting/viewer0D/viewer0D_main.py +0 -4
- pymodaq/daq_utils/plotting/viewer1D/__init__.py +0 -0
- pymodaq/daq_utils/plotting/viewer1D/viewer1D_main.py +0 -4
- pymodaq/daq_utils/plotting/viewer1D/viewer1Dbasic.py +0 -4
- pymodaq/daq_utils/plotting/viewer2D/viewer_2D_basic.py +0 -4
- pymodaq/daq_utils/plotting/viewer2D/viewer_2D_main.py +0 -4
- pymodaq/daq_utils/plotting/viewerND/__init__.py +0 -0
- pymodaq/daq_utils/plotting/viewerND/viewerND_main.py +0 -4
- pymodaq/daq_utils/scanner.py +0 -1289
- pymodaq/daq_utils/tree_layout/__init__.py +0 -0
- pymodaq/daq_viewer/__init__.py +0 -0
- pymodaq/daq_viewer/daq_gui_settings.py +0 -237
- pymodaq/daq_viewer/daq_gui_settings.ui +0 -441
- pymodaq/daq_viewer/daq_viewer_main.py +0 -2225
- pymodaq/daq_viewer/process_from_QtDesigner_DAQ_GUI_settings.bat +0 -2
- pymodaq/daq_viewer/utility_classes.py +0 -673
- pymodaq/examples/logger_image/__init__.py +0 -0
- pymodaq/examples/logger_image/logger_displayer.py +0 -121
- pymodaq/examples/logger_image/setup.svg +0 -3119
- pymodaq/examples/logger_image/setup_svg.py +0 -114
- pymodaq/h5browser.py +0 -39
- pymodaq/utils/scanner.py +0 -15
- pymodaq-3.6.12.dist-info/METADATA +0 -39
- pymodaq-3.6.12.dist-info/entry_points.txt +0 -8
- pymodaq-3.6.12.dist-info/top_level.txt +0 -1
- /pymodaq/{daq_analysis → post_treatment/daq_analysis}/__init__.py +0 -0
- /pymodaq/{daq_measurement → post_treatment/daq_measurement}/__init__.py +0 -0
- /pymodaq/{daq_measurement → post_treatment/daq_measurement}/daq_measurement_GUI.py +0 -0
- /pymodaq/{daq_measurement → post_treatment/daq_measurement}/daq_measurement_GUI.ui +0 -0
- /pymodaq/{daq_measurement → post_treatment/daq_measurement}/process_from_QtDesigner_DAQ_Measurement_GUI.bat +0 -0
- /pymodaq/{daq_utils → utils}/Tuto innosetup/Tuto innosetup.odt +0 -0
- /pymodaq/{daq_utils → utils}/Tuto innosetup/Tuto innosetup.pdf +0 -0
- /pymodaq/{daq_move → utils/db}/__init__.py +0 -0
- /pymodaq/{daq_utils → utils/db/db_logger}/__init__.py +0 -0
- /pymodaq/{daq_utils → utils}/gui_utils/dock.py +0 -0
- /pymodaq/{daq_utils → utils}/gui_utils/list_picker.py +0 -0
- /pymodaq/{daq_utils/abstract → utils/managers}/__init__.py +0 -0
- /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/bool.py +0 -0
- /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/date.py +0 -0
- /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/list.py +0 -0
- /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/numeric.py +0 -0
- /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/tableview.py +0 -0
- /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/text.py +0 -0
- /pymodaq/{daq_utils/db → utils/plotting}/__init__.py +0 -0
- /pymodaq/{daq_utils → utils}/plotting/image_viewer.py +0 -0
- /pymodaq/{daq_utils/db/db_logger → utils/plotting/items}/__init__.py +0 -0
- /pymodaq/{daq_utils → utils}/plotting/items/crosshair.py +0 -0
- /pymodaq/{daq_utils/managers → utils/plotting/utils}/__init__.py +0 -0
- /pymodaq/{daq_utils → utils}/qvariant.py +0 -0
- /pymodaq/{daq_utils/plotting/viewer2D → utils/scanner/scanners}/__init__.py +0 -0
- /pymodaq/{daq_utils/plotting → utils/tree_layout}/__init__.py +0 -0
- {pymodaq-3.6.12.dist-info → pymodaq-4.0.1.dist-info/licenses}/LICENSE +0 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from qtpy import QtWidgets, QtGui
|
|
3
|
+
from qtpy.QtCore import QByteArray, QObject
|
|
4
|
+
from pyqtgraph.parametertree.parameterTypes.basetypes import WidgetParameterItem, SimpleParameter
|
|
5
|
+
from qtpy import QtWidgets, QtGui
|
|
6
|
+
from qtpy.QtCore import QByteArray
|
|
7
|
+
from pyqtgraph.parametertree.parameterTypes.basetypes import WidgetParameterItem
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class PixmapCheckData:
|
|
11
|
+
def __init__(self, data: np.ndarray, path: str = '', checked: bool = False, info: str = ''):
|
|
12
|
+
if data is not None:
|
|
13
|
+
data = data / np.max(data) * 255
|
|
14
|
+
data = data.astype(np.uint8)
|
|
15
|
+
self.data = data[:, :]
|
|
16
|
+
else:
|
|
17
|
+
self.data = []
|
|
18
|
+
self.path = path
|
|
19
|
+
self.checked = checked
|
|
20
|
+
self.info = info
|
|
21
|
+
|
|
22
|
+
def __eq__(self, other):
|
|
23
|
+
if other is None:
|
|
24
|
+
return False
|
|
25
|
+
else:
|
|
26
|
+
status = np.all(np.isclose(self.data, other.data))
|
|
27
|
+
status = status and self.checked == other.checked
|
|
28
|
+
status = status and self.path == other.path
|
|
29
|
+
return status
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class PixmapCheckWidget(QtWidgets.QWidget):
|
|
33
|
+
""" value of this parameter is a PixmapCheckData
|
|
34
|
+
|
|
35
|
+
See Also
|
|
36
|
+
--------
|
|
37
|
+
PixmapCheckedData
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
def __init__(self):
|
|
41
|
+
|
|
42
|
+
super().__init__()
|
|
43
|
+
self._data: PixmapCheckData = None
|
|
44
|
+
self.checkbox: QtWidgets.QCheckBox = None
|
|
45
|
+
self.label: QtWidgets.QLabel = None
|
|
46
|
+
self.info_label: QtWidgets.QLabel = None
|
|
47
|
+
self.initUI()
|
|
48
|
+
|
|
49
|
+
def initUI(self):
|
|
50
|
+
"""
|
|
51
|
+
Init the User Interface.
|
|
52
|
+
"""
|
|
53
|
+
self.setLayout(QtWidgets.QHBoxLayout())
|
|
54
|
+
self.layout().setContentsMargins(0, 0, 0, 0)
|
|
55
|
+
self.label = QtWidgets.QLabel()
|
|
56
|
+
self.label.setMaximumWidth(100)
|
|
57
|
+
self.label.setMinimumHeight(50)
|
|
58
|
+
self.label.setMaximumHeight(50)
|
|
59
|
+
self.layout().addWidget(self.label)
|
|
60
|
+
|
|
61
|
+
ver_widget = QtWidgets.QWidget()
|
|
62
|
+
ver_widget.setLayout(QtWidgets.QVBoxLayout())
|
|
63
|
+
self.checkbox = QtWidgets.QCheckBox('Show/Hide')
|
|
64
|
+
self.info_label = QtWidgets.QLabel()
|
|
65
|
+
# self.info.setReadOnly(True)
|
|
66
|
+
self.checkbox.setChecked(False)
|
|
67
|
+
ver_widget.layout().addWidget(self.info_label)
|
|
68
|
+
ver_widget.layout().addWidget(self.checkbox)
|
|
69
|
+
ver_widget.layout().setSpacing(0)
|
|
70
|
+
ver_widget.layout().setContentsMargins(0, 0, 0, 0)
|
|
71
|
+
self.layout().addWidget(ver_widget)
|
|
72
|
+
|
|
73
|
+
def setValue(self, data: PixmapCheckData):
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
im = QtGui.QImage(data.data, *data.data.shape, QtGui.QImage.Format_Indexed8)
|
|
77
|
+
a = QtGui.QPixmap.fromImage(im)
|
|
78
|
+
|
|
79
|
+
self.label.setPixmap(a)
|
|
80
|
+
self.checkbox.setChecked(data.checked)
|
|
81
|
+
self.info_label.setText(data.info)
|
|
82
|
+
self._data = data
|
|
83
|
+
|
|
84
|
+
def value(self):
|
|
85
|
+
return PixmapCheckData(data=self._data.data if self._data is not None else None,
|
|
86
|
+
checked=self.checkbox.isChecked(),
|
|
87
|
+
info=self._data.info if self._data is not None else '',
|
|
88
|
+
path=self._data.path if self._data is not None else '')
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class PixmapParameterItem(WidgetParameterItem):
|
|
92
|
+
"""Registered parameter type which displays a QPixmap in a QLabel"""
|
|
93
|
+
|
|
94
|
+
def makeWidget(self):
|
|
95
|
+
w = QtWidgets.QLabel()
|
|
96
|
+
w.sigChanged = None
|
|
97
|
+
w.value = w.pixmap
|
|
98
|
+
w.setValue = w.setPixmap
|
|
99
|
+
return w
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class PixmapCheckParameterItem(WidgetParameterItem):
|
|
103
|
+
"""Registered parameter type which displays a PixmapCheckWidget custom widget"""
|
|
104
|
+
|
|
105
|
+
def makeWidget(self):
|
|
106
|
+
w = PixmapCheckWidget()
|
|
107
|
+
w.sigChanged = w.checkbox.clicked
|
|
108
|
+
w.value = w.value
|
|
109
|
+
w.setValue = w.setValue
|
|
110
|
+
self.hideWidget = False
|
|
111
|
+
return w
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def main_widget():
|
|
115
|
+
import sys
|
|
116
|
+
app = QtWidgets.QApplication(sys.argv)
|
|
117
|
+
prog = PixmapCheckWidget()
|
|
118
|
+
prog.show()
|
|
119
|
+
data = np.arange(128 * 256).reshape((256, 128))
|
|
120
|
+
data = data / np.max(data) * 255
|
|
121
|
+
data = data.astype(np.uint8)
|
|
122
|
+
prog.setValue(PixmapCheckData(data=data,
|
|
123
|
+
checked=True,
|
|
124
|
+
info='this is an info'))
|
|
125
|
+
|
|
126
|
+
def print_toggled(status):
|
|
127
|
+
print(f"toggled: {status}")
|
|
128
|
+
|
|
129
|
+
prog.checkbox.toggled.connect(print_toggled)
|
|
130
|
+
|
|
131
|
+
sys.exit(app.exec_())
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def main_parameter():
|
|
135
|
+
from pymodaq.utils.managers.parameter_manager import ParameterManager
|
|
136
|
+
data = np.arange(128 * 256).reshape((256, 128))
|
|
137
|
+
data = data / np.max(data) * 255
|
|
138
|
+
data = data.astype(np.uint8)
|
|
139
|
+
|
|
140
|
+
class PixmapParameter(ParameterManager):
|
|
141
|
+
params = {'title': 'Overlays', 'name': 'overlays', 'type': 'group', 'children': [
|
|
142
|
+
{'name': f'Overlay{0:03.0f}', 'type': 'pixmap_check',
|
|
143
|
+
'value': PixmapCheckData(data=data, checked=False,
|
|
144
|
+
info=f'This is an info')},
|
|
145
|
+
{'name': 'other', 'type': 'bool_push', 'value': True},
|
|
146
|
+
{'name': 'otherp', 'type': 'led_push', 'value': True},
|
|
147
|
+
]},
|
|
148
|
+
|
|
149
|
+
def value_changed(self, param):
|
|
150
|
+
print(f'Value changed for {param}: {param.value()}')
|
|
151
|
+
|
|
152
|
+
import sys
|
|
153
|
+
app = QtWidgets.QApplication(sys.argv)
|
|
154
|
+
prog = PixmapParameter()
|
|
155
|
+
prog.settings_tree.show()
|
|
156
|
+
|
|
157
|
+
sys.exit(app.exec_())
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
if __name__ == '__main__':
|
|
161
|
+
main_parameter()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from qtpy import QtWidgets, QtCore
|
|
2
2
|
from pyqtgraph.widgets.SpinBox import SpinBox
|
|
3
3
|
from pyqtgraph.parametertree.parameterTypes.basetypes import WidgetParameterItem
|
|
4
|
-
from pymodaq.
|
|
4
|
+
from pymodaq.utils.parameter.utils import scroll_log, scroll_linear
|
|
5
5
|
import numpy as np
|
|
6
6
|
|
|
7
7
|
|
|
@@ -54,7 +54,7 @@ class TableWidget(QtWidgets.QTableWidget):
|
|
|
54
54
|
item0 = QtWidgets.QTableWidgetItem(key)
|
|
55
55
|
item0.setFlags(item0.flags() ^ QtCore.Qt.ItemIsEditable)
|
|
56
56
|
if isinstance(value, float):
|
|
57
|
-
item1 = QtWidgets.QTableWidgetItem('{:.
|
|
57
|
+
item1 = QtWidgets.QTableWidgetItem('{:.3e}'.format(value))
|
|
58
58
|
else:
|
|
59
59
|
item1 = QtWidgets.QTableWidgetItem(str(value))
|
|
60
60
|
item1.setFlags(item1.flags() ^ QtCore.Qt.ItemIsEditable)
|
pymodaq/utils/parameter/utils.py
CHANGED
|
@@ -1,15 +1,210 @@
|
|
|
1
|
-
|
|
2
|
-
"""
|
|
3
|
-
Created the 27/10/2022
|
|
1
|
+
from __future__ import annotations
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
import numpy as np
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
from pymodaq.utils.parameter import Parameter
|
|
9
8
|
|
|
10
9
|
|
|
11
|
-
def
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
def get_widget_from_tree(parameter_tree, widget_instance):
|
|
11
|
+
widgets = []
|
|
12
|
+
for item in parameter_tree.listAllItems():
|
|
13
|
+
if hasattr(item, 'widget'):
|
|
14
|
+
if item.widget.__class__.__name__ == widget_instance.__name__:
|
|
15
|
+
widgets.append(item.widget)
|
|
16
|
+
return widgets
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def get_param_path(param):
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
Parameters
|
|
23
|
+
----------
|
|
24
|
+
param
|
|
25
|
+
|
|
26
|
+
Returns
|
|
27
|
+
-------
|
|
28
|
+
|
|
29
|
+
"""
|
|
30
|
+
path = [param.name()]
|
|
31
|
+
while param.parent() is not None:
|
|
32
|
+
path.append(param.parent().name())
|
|
33
|
+
param = param.parent()
|
|
34
|
+
return path[::-1]
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def iter_children(param, childlist=[]):
|
|
38
|
+
"""Get a list of parameters name under a given Parameter
|
|
39
|
+
| Returns all childrens names.
|
|
40
|
+
|
|
41
|
+
=============== ================================= ====================================
|
|
42
|
+
**Parameters** **Type** **Description**
|
|
43
|
+
*param* instance of pyqtgraph parameter the root node to be coursed
|
|
44
|
+
*childlist* list the child list recetion structure
|
|
45
|
+
=============== ================================= ====================================
|
|
46
|
+
|
|
47
|
+
Returns
|
|
48
|
+
-------
|
|
49
|
+
childlist : parameter list
|
|
50
|
+
The list of the children from the given node.
|
|
51
|
+
"""
|
|
52
|
+
for child in param.children():
|
|
53
|
+
childlist.append(child.name())
|
|
54
|
+
if 'group' in child.type():
|
|
55
|
+
childlist.extend(iter_children(child, []))
|
|
56
|
+
return childlist
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def iter_children_params(param, childlist=[]):
|
|
60
|
+
"""Get a list of parameters under a given Parameter
|
|
61
|
+
|
|
62
|
+
"""
|
|
63
|
+
for child in param.children():
|
|
64
|
+
childlist.append(child)
|
|
65
|
+
if 'group' in child.type():
|
|
66
|
+
childlist.extend(iter_children_params(child, []))
|
|
67
|
+
return childlist
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def get_param_from_name(parent, name) -> Parameter:
|
|
71
|
+
"""Get Parameter under parent whose name is name
|
|
72
|
+
|
|
73
|
+
Parameters
|
|
74
|
+
----------
|
|
75
|
+
parent: Parameter
|
|
76
|
+
name: str
|
|
77
|
+
|
|
78
|
+
Returns
|
|
79
|
+
-------
|
|
80
|
+
Parameter
|
|
81
|
+
"""
|
|
82
|
+
for child in parent.children():
|
|
83
|
+
if child.name() == name:
|
|
84
|
+
return child
|
|
85
|
+
if 'group' in child.type():
|
|
86
|
+
ch = get_param_from_name(child, name)
|
|
87
|
+
if ch is not None:
|
|
88
|
+
return ch
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def is_name_in_dict(dict_tmp, name):
|
|
92
|
+
if 'name' in dict_tmp:
|
|
93
|
+
if dict_tmp['name'] == name:
|
|
94
|
+
return True
|
|
95
|
+
return False
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def get_param_dict_from_name(parent_list, name, pop=False):
|
|
99
|
+
"""Get dict under parent whose name is name. The parent_list structure is the one used to init a Parameter object
|
|
100
|
+
|
|
101
|
+
Parameters
|
|
102
|
+
----------
|
|
103
|
+
parent_list: (list of dicts) as defined to init Parameter object
|
|
104
|
+
name: (str) value to find for the key: name
|
|
105
|
+
pop: (bool) if True remove the matched dict from parent
|
|
106
|
+
|
|
107
|
+
Returns
|
|
108
|
+
-------
|
|
109
|
+
dict the matched dict
|
|
110
|
+
"""
|
|
111
|
+
for index, parent_dict in enumerate(parent_list):
|
|
112
|
+
if is_name_in_dict(parent_dict, name):
|
|
113
|
+
if pop:
|
|
114
|
+
return parent_list.pop(index)
|
|
115
|
+
else:
|
|
116
|
+
return parent_dict
|
|
117
|
+
|
|
118
|
+
elif 'children' in parent_dict:
|
|
119
|
+
ch = get_param_dict_from_name(parent_dict['children'], name, pop)
|
|
120
|
+
if ch is not None:
|
|
121
|
+
return ch
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
if __name__ == '__main__': # pragma: no cover
|
|
126
|
+
parent = [
|
|
127
|
+
{'title': 'Spectro Settings:', 'name': 'spectro_settings', 'type': 'group', 'expanded': True,
|
|
128
|
+
'children': [
|
|
129
|
+
{'title': 'Home Wavelength (nm):', 'name': 'spectro_wl_home', 'type': 'float', 'value': 600, 'min': 0,
|
|
130
|
+
'readonly': False},
|
|
131
|
+
{'title': 'Grating Settings:', 'name': 'grating_settings', 'type': 'group', 'expanded': True,
|
|
132
|
+
'children': [
|
|
133
|
+
{'title': 'Grating:', 'name': 'grating', 'type': 'list'},
|
|
134
|
+
{'title': 'Lines (/mm):', 'name': 'lines', 'type': 'int', 'readonly': True},
|
|
135
|
+
{'title': 'Blaze WL (nm):', 'name': 'blaze', 'type': 'str', 'readonly': True},
|
|
136
|
+
]},
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
]
|
|
140
|
+
|
|
141
|
+
d = get_param_dict_from_name(parent, 'lines')
|
|
142
|
+
|
|
143
|
+
d['readonly'] = False
|
|
144
|
+
print(parent[0]['children'][1]['children'])
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def set_param_from_param(param_old, param_new):
|
|
148
|
+
"""
|
|
149
|
+
Walk through parameters children and set values using new parameter values.
|
|
150
|
+
"""
|
|
151
|
+
for child_old in param_old.children():
|
|
152
|
+
# try:
|
|
153
|
+
path = param_old.childPath(child_old)
|
|
154
|
+
child_new = param_new.child(*path)
|
|
155
|
+
param_type = child_old.type()
|
|
156
|
+
|
|
157
|
+
if 'group' not in param_type: # covers 'group', custom 'groupmove'...
|
|
158
|
+
# try:
|
|
159
|
+
if 'list' in param_type: # check if the value is in the limits of the old params (limits are usually set at initialization)
|
|
160
|
+
if child_new.value() not in child_old.opts['limits']:
|
|
161
|
+
child_old.opts['limits'].append(child_new.value())
|
|
162
|
+
|
|
163
|
+
child_old.setValue(child_new.value())
|
|
164
|
+
elif 'str' in param_type or 'browsepath' in param_type or 'text' in param_type:
|
|
165
|
+
if child_new.value() != "": # to make sure one doesnt overwrite something
|
|
166
|
+
child_old.setValue(child_new.value())
|
|
167
|
+
else:
|
|
168
|
+
child_old.setValue(child_new.value())
|
|
169
|
+
# except Exception as e:
|
|
170
|
+
# print(str(e))
|
|
171
|
+
else:
|
|
172
|
+
set_param_from_param(child_old, child_new)
|
|
173
|
+
# except Exception as e:
|
|
174
|
+
# print(str(e))
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def scroll_log(scroll_val, min_val, max_val):
|
|
178
|
+
"""
|
|
179
|
+
Convert a scroll value [0-100] to a log scale between min_val and max_val
|
|
180
|
+
Parameters
|
|
181
|
+
----------
|
|
182
|
+
scroll
|
|
183
|
+
min_val
|
|
184
|
+
max_val
|
|
185
|
+
Returns
|
|
186
|
+
-------
|
|
187
|
+
|
|
188
|
+
"""
|
|
189
|
+
assert scroll_val >= 0
|
|
190
|
+
assert scroll_val <= 100
|
|
191
|
+
value = scroll_val * (np.log10(max_val) - np.log10(min_val)) / 100 + np.log10(min_val)
|
|
192
|
+
return 10 ** value
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def scroll_linear(scroll_val, min_val, max_val):
|
|
196
|
+
"""
|
|
197
|
+
Convert a scroll value [0-100] to a linear scale between min_val and max_val
|
|
198
|
+
Parameters
|
|
199
|
+
----------
|
|
200
|
+
scroll
|
|
201
|
+
min_val
|
|
202
|
+
max_val
|
|
203
|
+
Returns
|
|
204
|
+
-------
|
|
205
|
+
|
|
206
|
+
"""
|
|
207
|
+
assert scroll_val >= 0
|
|
208
|
+
assert scroll_val <= 100
|
|
209
|
+
value = scroll_val * (max_val - min_val) / 100 + min_val
|
|
210
|
+
return value
|