pymodaq 3.6.13__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.

Files changed (233) hide show
  1. pymodaq/__init__.py +13 -6
  2. pymodaq/control_modules/__init__.py +0 -7
  3. pymodaq/control_modules/daq_move.py +965 -2
  4. pymodaq/control_modules/daq_move_ui.py +319 -0
  5. pymodaq/control_modules/daq_viewer.py +1573 -3
  6. pymodaq/control_modules/daq_viewer_ui.py +393 -0
  7. pymodaq/control_modules/mocks.py +51 -0
  8. pymodaq/control_modules/move_utility_classes.py +709 -8
  9. pymodaq/control_modules/utils.py +256 -0
  10. pymodaq/control_modules/viewer_utility_classes.py +663 -6
  11. pymodaq/daq_utils.py +89 -0
  12. pymodaq/dashboard.py +91 -72
  13. pymodaq/examples/custom_app.py +12 -11
  14. pymodaq/examples/custom_viewer.py +10 -10
  15. pymodaq/examples/function_plotter.py +16 -13
  16. pymodaq/examples/nonlinearscanner.py +8 -6
  17. pymodaq/examples/parameter_ex.py +7 -7
  18. pymodaq/examples/preset_MockCamera.xml +1 -0
  19. pymodaq/extensions/__init__.py +16 -0
  20. pymodaq/extensions/console.py +76 -0
  21. pymodaq/{daq_logger.py → extensions/daq_logger.py} +115 -65
  22. pymodaq/extensions/daq_scan.py +1339 -0
  23. pymodaq/extensions/daq_scan_ui.py +240 -0
  24. pymodaq/extensions/h5browser.py +23 -0
  25. pymodaq/{pid → extensions/pid}/__init__.py +4 -2
  26. pymodaq/{pid → extensions/pid}/daq_move_PID.py +2 -2
  27. pymodaq/{pid → extensions/pid}/pid_controller.py +48 -36
  28. pymodaq/{pid → extensions/pid}/utils.py +52 -6
  29. pymodaq/extensions/utils.py +40 -0
  30. pymodaq/post_treatment/__init__.py +6 -0
  31. pymodaq/{daq_analysis → post_treatment/daq_analysis}/daq_analysis_main.py +17 -17
  32. pymodaq/{daq_measurement → post_treatment/daq_measurement}/daq_measurement_main.py +8 -14
  33. pymodaq/post_treatment/load_and_plot.py +219 -0
  34. pymodaq/post_treatment/process_to_scalar.py +263 -0
  35. pymodaq/resources/QtDesigner_Ressources/Icon_Library/run_all.png +0 -0
  36. pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop_all.png +0 -0
  37. pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.bat +1 -1
  38. pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.qrc +1 -0
  39. pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources_rc.py +109784 -109173
  40. pymodaq/resources/QtDesigner_Ressources/icons.svg +142 -0
  41. pymodaq/resources/VERSION +1 -1
  42. pymodaq/resources/config_template.toml +32 -13
  43. pymodaq/resources/preset_default.xml +1 -1
  44. pymodaq/{daq_utils → utils}/Tuto innosetup/script_full_setup.iss +1 -1
  45. pymodaq/utils/__init__.py +0 -29
  46. pymodaq/utils/abstract/__init__.py +48 -0
  47. pymodaq/{daq_utils → utils}/abstract/logger.py +7 -3
  48. pymodaq/utils/array_manipulation.py +379 -8
  49. pymodaq/{daq_utils → utils}/calibration_camera.py +6 -6
  50. pymodaq/{daq_utils → utils}/chrono_timer.py +1 -1
  51. pymodaq/utils/config.py +448 -0
  52. pymodaq/utils/conftests.py +5 -0
  53. pymodaq/utils/daq_utils.py +828 -8
  54. pymodaq/utils/data.py +1873 -7
  55. pymodaq/{daq_utils → utils}/db/db_logger/db_logger.py +86 -47
  56. pymodaq/{daq_utils → utils}/db/db_logger/db_logger_models.py +31 -10
  57. pymodaq/{daq_utils → utils}/enums.py +12 -7
  58. pymodaq/utils/exceptions.py +37 -0
  59. pymodaq/utils/factory.py +82 -0
  60. pymodaq/{daq_utils → utils}/gui_utils/__init__.py +1 -1
  61. pymodaq/utils/gui_utils/custom_app.py +129 -0
  62. pymodaq/utils/gui_utils/file_io.py +66 -0
  63. pymodaq/{daq_utils → utils}/gui_utils/layout.py +2 -2
  64. pymodaq/{daq_utils → utils}/gui_utils/utils.py +13 -3
  65. pymodaq/{daq_utils → utils}/gui_utils/widgets/__init__.py +2 -2
  66. pymodaq/utils/gui_utils/widgets/label.py +24 -0
  67. pymodaq/{daq_utils → utils}/gui_utils/widgets/lcd.py +12 -7
  68. pymodaq/{daq_utils → utils}/gui_utils/widgets/push.py +66 -2
  69. pymodaq/{daq_utils → utils}/gui_utils/widgets/qled.py +6 -4
  70. pymodaq/utils/gui_utils/widgets/spinbox.py +24 -0
  71. pymodaq/{daq_utils → utils}/gui_utils/widgets/table.py +2 -2
  72. pymodaq/utils/h5modules/__init__.py +1 -0
  73. pymodaq/{daq_utils/h5backend.py → utils/h5modules/backends.py} +200 -112
  74. pymodaq/utils/h5modules/browsing.py +683 -0
  75. pymodaq/utils/h5modules/data_saving.py +839 -0
  76. pymodaq/utils/h5modules/h5logging.py +110 -0
  77. pymodaq/utils/h5modules/module_saving.py +350 -0
  78. pymodaq/utils/h5modules/saving.py +914 -0
  79. pymodaq/utils/h5modules/utils.py +85 -0
  80. pymodaq/utils/logger.py +64 -6
  81. pymodaq/utils/managers/action_manager.py +460 -0
  82. pymodaq/{daq_utils → utils}/managers/batchscan_manager.py +144 -112
  83. pymodaq/{daq_utils → utils}/managers/modules_manager.py +188 -114
  84. pymodaq/{daq_utils → utils}/managers/overshoot_manager.py +3 -3
  85. pymodaq/utils/managers/parameter_manager.py +110 -0
  86. pymodaq/{daq_utils → utils}/managers/preset_manager.py +17 -13
  87. pymodaq/{daq_utils → utils}/managers/preset_manager_utils.py +8 -7
  88. pymodaq/{daq_utils → utils}/managers/remote_manager.py +7 -6
  89. pymodaq/{daq_utils → utils}/managers/roi_manager.py +148 -57
  90. pymodaq/utils/math_utils.py +546 -10
  91. pymodaq/{daq_utils → utils}/messenger.py +5 -1
  92. pymodaq/utils/parameter/__init__.py +2 -15
  93. pymodaq/{daq_utils → utils}/parameter/ioxml.py +12 -6
  94. pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/__init__.py +1 -3
  95. pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/filedir.py +1 -1
  96. pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/itemselect.py +3 -0
  97. pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/led.py +1 -1
  98. pymodaq/utils/parameter/pymodaq_ptypes/pixmap.py +161 -0
  99. pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/slide.py +1 -1
  100. pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/table.py +1 -1
  101. pymodaq/utils/parameter/utils.py +206 -11
  102. pymodaq/utils/plotting/data_viewers/__init__.py +6 -0
  103. pymodaq/utils/plotting/data_viewers/viewer.py +393 -0
  104. pymodaq/utils/plotting/data_viewers/viewer0D.py +251 -0
  105. pymodaq/utils/plotting/data_viewers/viewer1D.py +574 -0
  106. pymodaq/{daq_utils → utils}/plotting/data_viewers/viewer1Dbasic.py +8 -3
  107. pymodaq/{daq_utils → utils}/plotting/data_viewers/viewer2D.py +292 -357
  108. pymodaq/{daq_utils → utils}/plotting/data_viewers/viewer2D_basic.py +58 -75
  109. pymodaq/utils/plotting/data_viewers/viewerND.py +738 -0
  110. pymodaq/{daq_utils → utils}/plotting/gant_chart.py +2 -2
  111. pymodaq/{daq_utils → utils}/plotting/items/axis_scaled.py +4 -2
  112. pymodaq/{daq_utils → utils}/plotting/items/image.py +8 -6
  113. pymodaq/utils/plotting/navigator.py +355 -0
  114. pymodaq/utils/plotting/scan_selector.py +480 -0
  115. pymodaq/utils/plotting/utils/axes_viewer.py +88 -0
  116. pymodaq/utils/plotting/utils/filter.py +538 -0
  117. pymodaq/utils/plotting/utils/lineout.py +224 -0
  118. pymodaq/{daq_utils → utils}/plotting/utils/plot_utils.py +196 -84
  119. pymodaq/{daq_utils → utils}/plotting/utils/signalND.py +21 -13
  120. pymodaq/utils/plotting/widgets.py +76 -0
  121. pymodaq/utils/scanner/__init__.py +10 -0
  122. pymodaq/utils/scanner/scan_factory.py +204 -0
  123. pymodaq/utils/scanner/scanner.py +271 -0
  124. pymodaq/utils/scanner/scanners/_1d_scanners.py +117 -0
  125. pymodaq/utils/scanner/scanners/_2d_scanners.py +293 -0
  126. pymodaq/utils/scanner/scanners/sequential.py +192 -0
  127. pymodaq/utils/scanner/scanners/tabular.py +294 -0
  128. pymodaq/utils/scanner/utils.py +83 -0
  129. pymodaq/utils/slicing.py +47 -0
  130. pymodaq/utils/svg/__init__.py +6 -0
  131. pymodaq/utils/svg/svg_renderer.py +20 -0
  132. pymodaq/utils/svg/svg_view.py +35 -0
  133. pymodaq/utils/svg/svg_viewer2D.py +51 -0
  134. pymodaq/{daq_utils → utils}/tcp_server_client.py +36 -37
  135. pymodaq/{daq_utils → utils}/tree_layout/tree_layout_main.py +50 -35
  136. pymodaq/utils/units.py +216 -0
  137. pymodaq-4.0.1.dist-info/METADATA +159 -0
  138. {pymodaq-3.6.13.dist-info → pymodaq-4.0.1.dist-info}/RECORD +167 -170
  139. {pymodaq-3.6.13.dist-info → pymodaq-4.0.1.dist-info}/WHEEL +1 -2
  140. pymodaq-4.0.1.dist-info/entry_points.txt +8 -0
  141. pymodaq/daq_move/daq_move_gui.py +0 -279
  142. pymodaq/daq_move/daq_move_gui.ui +0 -534
  143. pymodaq/daq_move/daq_move_main.py +0 -1042
  144. pymodaq/daq_move/process_from_QtDesigner_DAQ_Move_GUI.bat +0 -2
  145. pymodaq/daq_move/utility_classes.py +0 -686
  146. pymodaq/daq_scan.py +0 -2160
  147. pymodaq/daq_utils/array_manipulation.py +0 -386
  148. pymodaq/daq_utils/config.py +0 -273
  149. pymodaq/daq_utils/conftests.py +0 -7
  150. pymodaq/daq_utils/custom_parameter_tree.py +0 -9
  151. pymodaq/daq_utils/daq_enums.py +0 -133
  152. pymodaq/daq_utils/daq_utils.py +0 -1402
  153. pymodaq/daq_utils/exceptions.py +0 -71
  154. pymodaq/daq_utils/gui_utils/custom_app.py +0 -103
  155. pymodaq/daq_utils/gui_utils/file_io.py +0 -75
  156. pymodaq/daq_utils/gui_utils/widgets/spinbox.py +0 -9
  157. pymodaq/daq_utils/h5exporter_hyperspy.py +0 -115
  158. pymodaq/daq_utils/h5exporters.py +0 -242
  159. pymodaq/daq_utils/h5modules.py +0 -1559
  160. pymodaq/daq_utils/h5utils.py +0 -241
  161. pymodaq/daq_utils/managers/action_manager.py +0 -236
  162. pymodaq/daq_utils/managers/parameter_manager.py +0 -57
  163. pymodaq/daq_utils/math_utils.py +0 -705
  164. pymodaq/daq_utils/parameter/__init__.py +0 -1
  165. pymodaq/daq_utils/parameter/oldpymodaq_ptypes.py +0 -1626
  166. pymodaq/daq_utils/parameter/pymodaq_ptypes/pixmap.py +0 -85
  167. pymodaq/daq_utils/parameter/utils.py +0 -136
  168. pymodaq/daq_utils/plotting/data_viewers/__init__.py +0 -0
  169. pymodaq/daq_utils/plotting/data_viewers/process_from_QtDesigner_0DViewer_GUI.bat +0 -2
  170. pymodaq/daq_utils/plotting/data_viewers/viewer0D.py +0 -204
  171. pymodaq/daq_utils/plotting/data_viewers/viewer0D_GUI.py +0 -89
  172. pymodaq/daq_utils/plotting/data_viewers/viewer0D_GUI.ui +0 -131
  173. pymodaq/daq_utils/plotting/data_viewers/viewer1D.py +0 -781
  174. pymodaq/daq_utils/plotting/data_viewers/viewerND.py +0 -894
  175. pymodaq/daq_utils/plotting/data_viewers/viewerbase.py +0 -64
  176. pymodaq/daq_utils/plotting/items/__init__.py +0 -0
  177. pymodaq/daq_utils/plotting/navigator.py +0 -500
  178. pymodaq/daq_utils/plotting/scan_selector.py +0 -289
  179. pymodaq/daq_utils/plotting/utils/__init__.py +0 -0
  180. pymodaq/daq_utils/plotting/utils/filter.py +0 -236
  181. pymodaq/daq_utils/plotting/viewer0D/__init__.py +0 -0
  182. pymodaq/daq_utils/plotting/viewer0D/viewer0D_main.py +0 -4
  183. pymodaq/daq_utils/plotting/viewer1D/__init__.py +0 -0
  184. pymodaq/daq_utils/plotting/viewer1D/viewer1D_main.py +0 -4
  185. pymodaq/daq_utils/plotting/viewer1D/viewer1Dbasic.py +0 -4
  186. pymodaq/daq_utils/plotting/viewer2D/viewer_2D_basic.py +0 -4
  187. pymodaq/daq_utils/plotting/viewer2D/viewer_2D_main.py +0 -4
  188. pymodaq/daq_utils/plotting/viewerND/__init__.py +0 -0
  189. pymodaq/daq_utils/plotting/viewerND/viewerND_main.py +0 -4
  190. pymodaq/daq_utils/scanner.py +0 -1289
  191. pymodaq/daq_utils/tree_layout/__init__.py +0 -0
  192. pymodaq/daq_viewer/__init__.py +0 -0
  193. pymodaq/daq_viewer/daq_gui_settings.py +0 -237
  194. pymodaq/daq_viewer/daq_gui_settings.ui +0 -441
  195. pymodaq/daq_viewer/daq_viewer_main.py +0 -2225
  196. pymodaq/daq_viewer/process_from_QtDesigner_DAQ_GUI_settings.bat +0 -2
  197. pymodaq/daq_viewer/utility_classes.py +0 -673
  198. pymodaq/examples/logger_image/__init__.py +0 -0
  199. pymodaq/examples/logger_image/logger_displayer.py +0 -121
  200. pymodaq/examples/logger_image/setup.svg +0 -3119
  201. pymodaq/examples/logger_image/setup_svg.py +0 -114
  202. pymodaq/h5browser.py +0 -39
  203. pymodaq/utils/scanner.py +0 -15
  204. pymodaq-3.6.13.dist-info/METADATA +0 -39
  205. pymodaq-3.6.13.dist-info/entry_points.txt +0 -8
  206. pymodaq-3.6.13.dist-info/top_level.txt +0 -1
  207. /pymodaq/{daq_analysis → post_treatment/daq_analysis}/__init__.py +0 -0
  208. /pymodaq/{daq_measurement → post_treatment/daq_measurement}/__init__.py +0 -0
  209. /pymodaq/{daq_measurement → post_treatment/daq_measurement}/daq_measurement_GUI.py +0 -0
  210. /pymodaq/{daq_measurement → post_treatment/daq_measurement}/daq_measurement_GUI.ui +0 -0
  211. /pymodaq/{daq_measurement → post_treatment/daq_measurement}/process_from_QtDesigner_DAQ_Measurement_GUI.bat +0 -0
  212. /pymodaq/{daq_utils → utils}/Tuto innosetup/Tuto innosetup.odt +0 -0
  213. /pymodaq/{daq_utils → utils}/Tuto innosetup/Tuto innosetup.pdf +0 -0
  214. /pymodaq/{daq_move → utils/db}/__init__.py +0 -0
  215. /pymodaq/{daq_utils → utils/db/db_logger}/__init__.py +0 -0
  216. /pymodaq/{daq_utils → utils}/gui_utils/dock.py +0 -0
  217. /pymodaq/{daq_utils → utils}/gui_utils/list_picker.py +0 -0
  218. /pymodaq/{daq_utils/abstract → utils/managers}/__init__.py +0 -0
  219. /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/bool.py +0 -0
  220. /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/date.py +0 -0
  221. /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/list.py +0 -0
  222. /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/numeric.py +0 -0
  223. /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/tableview.py +0 -0
  224. /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/text.py +0 -0
  225. /pymodaq/{daq_utils/db → utils/plotting}/__init__.py +0 -0
  226. /pymodaq/{daq_utils → utils}/plotting/image_viewer.py +0 -0
  227. /pymodaq/{daq_utils/db/db_logger → utils/plotting/items}/__init__.py +0 -0
  228. /pymodaq/{daq_utils → utils}/plotting/items/crosshair.py +0 -0
  229. /pymodaq/{daq_utils/managers → utils/plotting/utils}/__init__.py +0 -0
  230. /pymodaq/{daq_utils → utils}/qvariant.py +0 -0
  231. /pymodaq/{daq_utils/plotting/viewer2D → utils/scanner/scanners}/__init__.py +0 -0
  232. /pymodaq/{daq_utils/plotting → utils/tree_layout}/__init__.py +0 -0
  233. {pymodaq-3.6.13.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.daq_utils.daq_utils import scroll_log, scroll_linear
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('{:.6e}'.format(value))
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)
@@ -1,15 +1,210 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Created the 27/10/2022
1
+ from __future__ import annotations
4
2
 
5
- @author: Sebastien Weber
6
- """
3
+ from typing import TYPE_CHECKING
4
+ import numpy as np
7
5
 
8
- from pymodaq.daq_utils.parameter import utils
6
+ if TYPE_CHECKING:
7
+ from pymodaq.utils.parameter import Parameter
9
8
 
10
9
 
11
- def __getattr__(name):
12
- if hasattr(utils, name):
13
- return getattr(utils, name)
14
- else:
15
- raise AttributeError
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
@@ -0,0 +1,6 @@
1
+ from .viewer0D import Viewer0D
2
+ from .viewer1D import Viewer1D
3
+ from .viewer2D import Viewer2D
4
+ from .viewerND import ViewerND
5
+
6
+ DATA_TYPES = ['Data0D', 'Data1D', 'Data2D', 'DataND']