pymodaq 5.0.17__py3-none-any.whl → 5.1.0__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 (92) hide show
  1. pymodaq/__init__.py +23 -11
  2. pymodaq/control_modules/__init__.py +1 -0
  3. pymodaq/control_modules/daq_move.py +458 -246
  4. pymodaq/control_modules/daq_move_ui/__init__.py +0 -0
  5. pymodaq/control_modules/daq_move_ui/factory.py +48 -0
  6. pymodaq/control_modules/{daq_move_ui.py → daq_move_ui/ui_base.py} +168 -210
  7. pymodaq/control_modules/daq_move_ui/uis/__init__.py +0 -0
  8. pymodaq/control_modules/daq_move_ui/uis/binary.py +139 -0
  9. pymodaq/control_modules/daq_move_ui/uis/original.py +120 -0
  10. pymodaq/control_modules/daq_move_ui/uis/relative.py +124 -0
  11. pymodaq/control_modules/daq_move_ui/uis/simple.py +126 -0
  12. pymodaq/control_modules/daq_viewer.py +113 -101
  13. pymodaq/control_modules/daq_viewer_ui.py +41 -31
  14. pymodaq/control_modules/mocks.py +2 -2
  15. pymodaq/control_modules/move_utility_classes.py +113 -41
  16. pymodaq/control_modules/thread_commands.py +137 -0
  17. pymodaq/control_modules/ui_utils.py +72 -0
  18. pymodaq/control_modules/utils.py +107 -63
  19. pymodaq/control_modules/viewer_utility_classes.py +13 -17
  20. pymodaq/dashboard.py +1294 -625
  21. pymodaq/examples/qt_less_standalone_module.py +48 -11
  22. pymodaq/extensions/__init__.py +8 -3
  23. pymodaq/extensions/adaptive/__init__.py +2 -0
  24. pymodaq/extensions/adaptive/adaptive_optimization.py +179 -0
  25. pymodaq/extensions/adaptive/loss_function/_1d_loss_functions.py +73 -0
  26. pymodaq/extensions/adaptive/loss_function/_2d_loss_functions.py +73 -0
  27. pymodaq/extensions/adaptive/loss_function/__init__.py +3 -0
  28. pymodaq/extensions/adaptive/loss_function/loss_factory.py +110 -0
  29. pymodaq/extensions/adaptive/utils.py +123 -0
  30. pymodaq/extensions/bayesian/__init__.py +1 -1
  31. pymodaq/extensions/bayesian/acquisition/__init__.py +2 -0
  32. pymodaq/extensions/bayesian/acquisition/acquisition_function_factory.py +80 -0
  33. pymodaq/extensions/bayesian/acquisition/base_acquisition_function.py +105 -0
  34. pymodaq/extensions/bayesian/bayesian_optimization.py +143 -0
  35. pymodaq/extensions/bayesian/utils.py +71 -297
  36. pymodaq/extensions/daq_logger/daq_logger.py +7 -12
  37. pymodaq/extensions/daq_logger/h5logging.py +1 -1
  38. pymodaq/extensions/daq_scan.py +30 -55
  39. pymodaq/extensions/data_mixer/__init__.py +0 -0
  40. pymodaq/extensions/data_mixer/daq_0Dviewer_DataMixer.py +97 -0
  41. pymodaq/extensions/data_mixer/data_mixer.py +262 -0
  42. pymodaq/extensions/data_mixer/model.py +108 -0
  43. pymodaq/extensions/data_mixer/models/__init__.py +0 -0
  44. pymodaq/extensions/data_mixer/models/equation_model.py +91 -0
  45. pymodaq/extensions/data_mixer/models/gaussian_fit_model.py +65 -0
  46. pymodaq/extensions/data_mixer/parser.py +53 -0
  47. pymodaq/extensions/data_mixer/utils.py +23 -0
  48. pymodaq/extensions/h5browser.py +3 -34
  49. pymodaq/extensions/optimizers_base/__init__.py +0 -0
  50. pymodaq/extensions/optimizers_base/optimizer.py +1016 -0
  51. pymodaq/extensions/optimizers_base/thread_commands.py +22 -0
  52. pymodaq/extensions/optimizers_base/utils.py +427 -0
  53. pymodaq/extensions/pid/actuator_controller.py +3 -2
  54. pymodaq/extensions/pid/daq_move_PID.py +107 -30
  55. pymodaq/extensions/pid/pid_controller.py +613 -287
  56. pymodaq/extensions/pid/utils.py +8 -5
  57. pymodaq/extensions/utils.py +17 -2
  58. pymodaq/resources/config_template.toml +57 -0
  59. pymodaq/resources/preset_default.xml +1 -1
  60. pymodaq/utils/config.py +13 -4
  61. pymodaq/utils/daq_utils.py +14 -0
  62. pymodaq/utils/data.py +1 -0
  63. pymodaq/utils/gui_utils/loader_utils.py +25 -15
  64. pymodaq/utils/h5modules/module_saving.py +134 -22
  65. pymodaq/utils/leco/daq_move_LECODirector.py +123 -84
  66. pymodaq/utils/leco/daq_xDviewer_LECODirector.py +84 -97
  67. pymodaq/utils/leco/director_utils.py +32 -16
  68. pymodaq/utils/leco/leco_director.py +104 -27
  69. pymodaq/utils/leco/pymodaq_listener.py +186 -97
  70. pymodaq/utils/leco/rpc_method_definitions.py +43 -0
  71. pymodaq/utils/leco/utils.py +25 -25
  72. pymodaq/utils/managers/batchscan_manager.py +12 -11
  73. pymodaq/utils/managers/modules_manager.py +74 -33
  74. pymodaq/utils/managers/overshoot_manager.py +11 -10
  75. pymodaq/utils/managers/preset_manager.py +100 -64
  76. pymodaq/utils/managers/preset_manager_utils.py +163 -107
  77. pymodaq/utils/managers/remote_manager.py +21 -16
  78. pymodaq/utils/scanner/scan_factory.py +18 -4
  79. pymodaq/utils/scanner/scan_selector.py +1 -3
  80. pymodaq/utils/scanner/scanner.py +35 -6
  81. pymodaq/utils/scanner/scanners/_1d_scanners.py +15 -46
  82. pymodaq/utils/scanner/scanners/_2d_scanners.py +21 -68
  83. pymodaq/utils/scanner/scanners/sequential.py +50 -31
  84. pymodaq/utils/scanner/scanners/tabular.py +45 -28
  85. {pymodaq-5.0.17.dist-info → pymodaq-5.1.0.dist-info}/METADATA +7 -6
  86. pymodaq-5.1.0.dist-info/RECORD +154 -0
  87. {pymodaq-5.0.17.dist-info → pymodaq-5.1.0.dist-info}/entry_points.txt +0 -2
  88. pymodaq/extensions/bayesian/bayesian_optimisation.py +0 -685
  89. pymodaq/utils/leco/desktop.ini +0 -2
  90. pymodaq-5.0.17.dist-info/RECORD +0 -121
  91. {pymodaq-5.0.17.dist-info → pymodaq-5.1.0.dist-info}/WHEEL +0 -0
  92. {pymodaq-5.0.17.dist-info → pymodaq-5.1.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,4 +1,4 @@
1
- from typing import List, Union, TYPE_CHECKING
1
+ from typing import List, Union, TYPE_CHECKING, Optional, Sequence
2
2
 
3
3
  from collections import OrderedDict
4
4
  from qtpy.QtCore import QObject, Signal, Slot, QThread
@@ -15,14 +15,16 @@ from pymodaq_gui.managers.parameter_manager import ParameterManager
15
15
  from pymodaq_gui.utils import Dock
16
16
 
17
17
  from pymodaq.utils.data import DataActuator
18
-
18
+ from pymodaq.utils.config import Config as ControlModulesConfig
19
19
 
20
20
  if TYPE_CHECKING:
21
21
  from pymodaq.control_modules.daq_viewer import DAQ_Viewer
22
22
  from pymodaq.control_modules.daq_move import DAQ_Move
23
23
 
24
24
  logger = set_logger(get_module_name(__file__))
25
- config = Config()
25
+
26
+ config_utils = Config()
27
+ config = ControlModulesConfig()
26
28
 
27
29
 
28
30
  class ModulesManager(QObject, ParameterManager):
@@ -68,9 +70,26 @@ class ModulesManager(QObject, ParameterManager):
68
70
  ]},
69
71
  ]
70
72
 
71
- def __init__(self, detectors=[], actuators=[], selected_detectors=[], selected_actuators=[], **kwargs):
73
+ def __init__(self,
74
+ detectors: Optional[Sequence['DAQ_Viewer']] = None,
75
+ actuators: Optional[Sequence['DAQ_Move']] = None,
76
+ selected_detectors: Optional[Sequence['DAQ_Viewer']] = None,
77
+ selected_actuators: Optional[Sequence['DAQ_Move']] = None,
78
+ parent_name='',
79
+ **kwargs):
80
+
72
81
  QObject.__init__(self)
73
82
  ParameterManager.__init__(self)
83
+ if detectors is None:
84
+ detectors = []
85
+ if actuators is None:
86
+ actuators = []
87
+ if selected_detectors is None:
88
+ selected_detectors = []
89
+ if selected_actuators is None:
90
+ selected_actuators = []
91
+
92
+ self.parent_name = parent_name
74
93
 
75
94
  for mod in selected_actuators:
76
95
  assert mod in actuators
@@ -100,6 +119,9 @@ class ModulesManager(QObject, ParameterManager):
100
119
  self.set_actuators(actuators, selected_actuators)
101
120
  self.set_detectors(detectors, selected_detectors)
102
121
 
122
+ def __repr__(self):
123
+ return f'ModulesManager of "{self.parent_name}" with control modules: {self.get_names(self.modules_all)}'
124
+
103
125
  def show_only_control_modules(self, show: True):
104
126
  self.settings.child('move_done').show(not show)
105
127
  self.settings.child('det_done').show(not show)
@@ -197,7 +219,7 @@ class ModulesManager(QObject, ParameterManager):
197
219
 
198
220
  @property
199
221
  def modules(self):
200
- """Get the list of all detectors and actuators"""
222
+ """Get the list of detectors and actuators"""
201
223
  return self.detectors + self.actuators
202
224
 
203
225
  @property
@@ -257,25 +279,28 @@ class ModulesManager(QObject, ParameterManager):
257
279
  def get_det_data_list(self) -> DataToExport:
258
280
  """Do a snap of selected detectors, to get the list of all the data and processed data"""
259
281
 
260
- self.connect_detectors()
261
- datas: DataToExport = self.grab_data()
262
-
263
- data_list0D = datas.get_full_names('data0D')
264
- data_list1D = datas.get_full_names('data1D')
265
- data_list2D = datas.get_full_names('data2D')
266
- data_listND = datas.get_full_names('dataND')
267
-
268
- self.settings.child('data_dimensions', 'det_data_list0D').setValue(
269
- dict(all_items=data_list0D, selected=[]))
270
- self.settings.child('data_dimensions', 'det_data_list1D').setValue(
271
- dict(all_items=data_list1D, selected=[]))
272
- self.settings.child('data_dimensions', 'det_data_list2D').setValue(
273
- dict(all_items=data_list2D, selected=[]))
274
- self.settings.child('data_dimensions', 'det_data_listND').setValue(
275
- dict(all_items=data_listND, selected=[]))
276
-
277
- self.connect_detectors(False)
278
- return datas
282
+ if len(self.detectors) == 0:
283
+ return DataToExport(name=__class__.__name__, control_module='DAQ_Viewer')
284
+ else:
285
+ self.connect_detectors()
286
+ datas: DataToExport = self.grab_data()
287
+
288
+ data_list0D = datas.get_full_names('data0D')
289
+ data_list1D = datas.get_full_names('data1D')
290
+ data_list2D = datas.get_full_names('data2D')
291
+ data_listND = datas.get_full_names('dataND')
292
+
293
+ self.settings.child('data_dimensions', 'det_data_list0D').setValue(
294
+ dict(all_items=data_list0D, selected=[]))
295
+ self.settings.child('data_dimensions', 'det_data_list1D').setValue(
296
+ dict(all_items=data_list1D, selected=[]))
297
+ self.settings.child('data_dimensions', 'det_data_list2D').setValue(
298
+ dict(all_items=data_list2D, selected=[]))
299
+ self.settings.child('data_dimensions', 'det_data_listND').setValue(
300
+ dict(all_items=data_listND, selected=[]))
301
+
302
+ self.connect_detectors(False)
303
+ return datas
279
304
 
280
305
  def get_selected_probed_data(self, dim='0D'):
281
306
  """Get the name of selected data names of a given dimensionality
@@ -287,26 +312,42 @@ class ModulesManager(QObject, ParameterManager):
287
312
  """
288
313
  return self.settings.child('data_dimensions', f'det_data_list{dim.upper()}').value()['selected']
289
314
 
290
- def grab_data(self, **kwargs):
291
- """Do a single grab of connected and selected detectors"""
315
+ def grab_data(self, check_do_override=True, **kwargs):
316
+ """Do a single grab of connected and selected detectors
317
+
318
+ Parameter
319
+ ---------
320
+ check_do_override: bool
321
+ If this is True the signal emission to the DAQ_Viewers will be conditionned to the status of their internal
322
+ override_grab_from_extension attribute
323
+ """
292
324
  self.det_done_datas = DataToExport(name=__class__.__name__, control_module='DAQ_Viewer')
293
325
  self._received_data = 0
294
326
  self.det_done_flag = False
295
327
  self.settings.child('det_done').setValue(self.det_done_flag)
296
328
  tzero = time.perf_counter()
329
+
330
+ if 'DataMixer' in self.selected_detectors_name:
331
+ overridden_detectors = self.get_mod_from_name(
332
+ 'DataMixer', 'det').settings.child(
333
+ 'detector_settings', 'overridden_detectors').opts['limits']
334
+ else:
335
+ overridden_detectors = []
297
336
 
298
337
  for mod in self.detectors:
299
- kwargs.update(dict(Naverage=mod.Naverage))
300
- mod.command_hardware.emit(utils.ThreadCommand("single", kwargs))
338
+ #if not (check_do_override and mod.override_grab_from_extension):
339
+ if mod.title not in overridden_detectors:
340
+ kwargs.update(dict(Naverage=mod.Naverage))
341
+ mod.command_hardware.emit(utils.ThreadCommand("single", kwargs))
301
342
 
302
343
  while not self.det_done_flag:
303
344
  # wait for grab done signals to end
304
-
305
- QtWidgets.QApplication.processEvents()
306
- if time.perf_counter() - tzero > self.detector_timeout:
345
+ QtWidgets.QApplication.processEvents() # mandatory for the det_done_flag boolean to be modified in the corresponding method
346
+ if time.perf_counter() - tzero > self.detector_timeout / 1000:
307
347
  self.timeout_signal.emit(True)
308
348
  logger.error('Timeout Fired during waiting for data to be acquired')
309
349
  break
350
+ QThread.msleep(10)
310
351
 
311
352
  self.det_done_signal.emit(self.det_done_datas)
312
353
  return self.det_done_datas
@@ -453,12 +494,12 @@ class ModulesManager(QObject, ParameterManager):
453
494
  if polling:
454
495
  while not self.move_done_flag: # polling move done
455
496
 
456
- QtWidgets.QApplication.processEvents()
497
+ QtWidgets.QApplication.processEvents() # mandatory for the det_done_flag boolean to be modified in the corresponding method
457
498
  if time.perf_counter() - tzero > self.actuator_timeout / 1000: # timeout in seconds
458
499
  self.timeout_signal.emit(True)
459
500
  logger.error('Timeout Fired during waiting for actuators to be moved')
460
501
  break
461
- QThread.msleep(20)
502
+ QThread.msleep(10)
462
503
 
463
504
  self.move_done_signal.emit(self.move_done_positions)
464
505
  return self.move_done_positions
@@ -1,4 +1,5 @@
1
1
  from qtpy import QtWidgets
2
+ from qtpy.QtWidgets import QMessageBox, QDialogButtonBox, QDialog
2
3
  import sys
3
4
  import os
4
5
 
@@ -121,13 +122,13 @@ class OvershootManager:
121
122
  self._activated = False
122
123
 
123
124
  if msgbox:
124
- msgBox = QtWidgets.QMessageBox()
125
+ msgBox = QMessageBox()
125
126
  msgBox.setText("Overshoot Manager?")
126
127
  msgBox.setInformativeText("What do you want to do?")
127
- cancel_button = msgBox.addButton(QtWidgets.QMessageBox.Cancel)
128
- new_button = msgBox.addButton("New", QtWidgets.QMessageBox.ActionRole)
129
- modify_button = msgBox.addButton('Modify', QtWidgets.QMessageBox.AcceptRole)
130
- msgBox.setDefaultButton(QtWidgets.QMessageBox.Cancel)
128
+ cancel_button = msgBox.addButton(QMessageBox.StandardButton.Cancel)
129
+ new_button = msgBox.addButton("New", QMessageBox.ButtonRole.ActionRole)
130
+ modify_button = msgBox.addButton("Modify", QMessageBox.ButtonRole.AcceptRole)
131
+ msgBox.setDefaultButton(QMessageBox.StandardButton.Cancel)
131
132
  ret = msgBox.exec()
132
133
 
133
134
  if msgBox.clickedButton() == new_button:
@@ -173,7 +174,7 @@ class OvershootManager:
173
174
  """
174
175
 
175
176
  """
176
- dialog = QtWidgets.QDialog()
177
+ dialog = QDialog()
177
178
  vlayout = QtWidgets.QVBoxLayout()
178
179
  tree = ParameterTree()
179
180
  tree.setMinimumWidth(400)
@@ -182,18 +183,18 @@ class OvershootManager:
182
183
 
183
184
  vlayout.addWidget(tree)
184
185
  dialog.setLayout(vlayout)
185
- buttonBox = QtWidgets.QDialogButtonBox(parent=dialog)
186
+ buttonBox = QDialogButtonBox(parent=dialog)
186
187
 
187
- buttonBox.addButton('Save', buttonBox.AcceptRole)
188
+ buttonBox.addButton("Save", QDialogButtonBox.ButtonRole.AcceptRole)
188
189
  buttonBox.accepted.connect(dialog.accept)
189
- buttonBox.addButton('Cancel', buttonBox.RejectRole)
190
+ buttonBox.addButton("Cancel", QDialogButtonBox.ButtonRole.RejectRole)
190
191
  buttonBox.rejected.connect(dialog.reject)
191
192
 
192
193
  vlayout.addWidget(buttonBox)
193
194
  dialog.setWindowTitle('Fill in information about this managers')
194
195
  res = dialog.exec()
195
196
 
196
- if res == dialog.Accepted:
197
+ if res == QDialog.DialogCode.Accepted:
197
198
  # save managers parameters in a xml file
198
199
  # start = os.path.split(os.path.split(os.path.realpath(__file__))[0])[0]
199
200
  # start = os.path.join("..",'daq_scan')
@@ -3,6 +3,7 @@ from pathlib import Path
3
3
  import sys
4
4
 
5
5
  from qtpy import QtWidgets
6
+ from qtpy.QtWidgets import QMessageBox, QDialogButtonBox, QDialog
6
7
 
7
8
  import pymodaq_utils.config as config_mod
8
9
  from pymodaq_utils.logger import set_logger, get_module_name
@@ -26,7 +27,6 @@ layout_path = config_mod_pymodaq.get_set_layout_path()
26
27
 
27
28
  class PresetManager:
28
29
  def __init__(self, msgbox=False, path=None, extra_params=[], param_options=[]):
29
-
30
30
  if path is None:
31
31
  path = preset_path
32
32
  else:
@@ -38,21 +38,25 @@ class PresetManager:
38
38
  self.preset_params: Parameter = None
39
39
 
40
40
  if msgbox:
41
- msgBox = QtWidgets.QMessageBox()
41
+ msgBox = QMessageBox()
42
42
  msgBox.setText("Preset Manager?")
43
43
  msgBox.setInformativeText("What do you want to do?")
44
- cancel_button = msgBox.addButton(QtWidgets.QMessageBox.Cancel)
45
- new_button = msgBox.addButton("New", QtWidgets.QMessageBox.ActionRole)
46
- modify_button = msgBox.addButton('Modify', QtWidgets.QMessageBox.AcceptRole)
47
- msgBox.setDefaultButton(QtWidgets.QMessageBox.Cancel)
44
+ cancel_button = msgBox.addButton(QMessageBox.StandardButton.Cancel)
45
+ new_button = msgBox.addButton(
46
+ "New", QMessageBox.ButtonRole.ActionRole
47
+ )
48
+ modify_button = msgBox.addButton(
49
+ "Modify", QMessageBox.ButtonRole.AcceptRole
50
+ )
51
+ msgBox.setDefaultButton(QMessageBox.StandardButton.Cancel)
48
52
  ret = msgBox.exec()
49
53
 
50
54
  if msgBox.clickedButton() == new_button:
51
55
  self.set_new_preset()
52
56
 
53
57
  elif msgBox.clickedButton() == modify_button:
54
- path = select_file(start_path=self.preset_path, save=False, ext='xml')
55
- if path != '':
58
+ path = select_file(start_path=self.preset_path, save=False, ext="xml")
59
+ if path != "":
56
60
  self.set_file_preset(str(path))
57
61
  else: # cancel
58
62
  pass
@@ -60,37 +64,55 @@ class PresetManager:
60
64
  @property
61
65
  def filename(self) -> str:
62
66
  try:
63
- return self.preset_params['filename']
67
+ return self.preset_params["filename"]
64
68
  except:
65
69
  return None
66
70
 
67
71
  def set_file_preset(self, filename, show=True):
68
- """
69
-
70
- """
72
+ """ """
71
73
  status = False
72
74
  children = ioxml.XML_file_to_parameter(filename)
73
- self.preset_params = Parameter.create(title='Preset', name='Preset', type='group', children=children)
75
+ self.preset_params = Parameter.create(
76
+ title="Preset", name="Preset", type="group", children=children
77
+ )
74
78
  if show:
75
79
  status = self.show_preset()
76
80
  return status
77
81
 
78
-
79
82
  def set_new_preset(self):
80
83
  param = [
81
- {'title': 'Filename:', 'name': 'filename', 'type': 'str', 'value': 'preset_default'},
82
- {'title': 'Model Settings:', 'name': 'model_settings', 'type': 'group', 'visible': False, 'children': []},
84
+ {
85
+ "title": "Filename:",
86
+ "name": "filename",
87
+ "type": "str",
88
+ "value": "preset_default",
89
+ },
90
+ {
91
+ "title": "Model Settings:",
92
+ "name": "model_settings",
93
+ "type": "group",
94
+ "visible": False,
95
+ "children": [],
96
+ },
83
97
  ]
84
98
  params_move = [
85
- {'title': 'Moves:', 'name': 'Moves', 'type': 'groupmove'}] # PresetScalableGroupMove(name="Moves")]
86
- params_det = [{'title': 'Detectors:', 'name': 'Detectors',
87
- 'type': 'groupdet'}] # [PresetScalableGroupDet(name="Detectors")]
88
- self.preset_params = Parameter.create(title='Preset', name='Preset', type='group',
89
- children=param + self.extra_params + params_move + params_det)
99
+ {"title": "Moves:", "name": "Moves", "type": "groupmove"}
100
+ ] # PresetScalableGroupMove(name="Moves")]
101
+ params_det = [
102
+ {"title": "Detectors:", "name": "Detectors", "type": "groupdet"}
103
+ ] # [PresetScalableGroupDet(name="Detectors")]
104
+ self.preset_params = Parameter.create(
105
+ title="Preset",
106
+ name="Preset",
107
+ type="group",
108
+ children=param + self.extra_params + params_move + params_det,
109
+ )
90
110
  try:
91
111
  for option in self.param_options:
92
- if 'path' in option and 'options_dict' in option:
93
- self.preset_params.child(option['path']).setOpts(**option['options_dict'])
112
+ if "path" in option and "options_dict" in option:
113
+ self.preset_params.child(option["path"]).setOpts(
114
+ **option["options_dict"]
115
+ )
94
116
  except Exception as e:
95
117
  logger.exception(str(e))
96
118
 
@@ -101,91 +123,105 @@ class PresetManager:
101
123
 
102
124
  def parameter_tree_changed(self, param, changes):
103
125
  """
104
- Check for changes in the given (parameter,change,information) tuple list.
105
- In case of value changed, update the DAQscan_settings tree consequently.
106
-
107
- =============== ============================================ ==============================
108
- **Parameters** **Type** **Description**
109
- *param* instance of pyqtgraph parameter the parameter to be checked
110
- *changes* (parameter,change,information) tuple list the current changes state
111
- =============== ============================================ ==============================
126
+ Check for changes in the given (parameter,change,information) tuple list.
127
+ In case of value changed, update the DAQscan_settings tree consequently.
128
+
129
+ =============== ============================================ ==============================
130
+ **Parameters** **Type** **Description**
131
+ *param* instance of pyqtgraph parameter the parameter to be checked
132
+ *changes* (parameter,change,information) tuple list the current changes state
133
+ =============== ============================================ ==============================
112
134
  """
113
135
  for param, change, data in changes:
114
136
  path = self.preset_params.childPath(param)
115
- if change == 'childAdded':
137
+ if change == "childAdded":
116
138
  if len(data) > 1:
117
- if 'params' in data[0].children():
118
- data[0].child('params', 'main_settings', 'module_name').setValue(data[0].child('name').value())
119
-
120
- elif change == 'value':
121
- if param.name() == 'name':
122
- param.parent().child('params', 'main_settings', 'module_name').setValue(param.value())
123
-
124
- elif change == 'parent':
139
+ if "params" in data[0].children():
140
+ data[0].child(
141
+ "params", "main_settings", "module_name"
142
+ ).setValue(data[0].child("name").value())
143
+
144
+ elif change == "value":
145
+ if param.name() == "name":
146
+ param.parent().child(
147
+ "params", "main_settings", "module_name"
148
+ ).setValue(param.value())
149
+
150
+ elif change == "parent":
125
151
  pass
126
152
 
127
153
  def show_preset(self):
128
- """
129
-
130
- """
131
- dialog = QtWidgets.QDialog()
154
+ """ """
155
+ dialog = QDialog()
132
156
  vlayout = QtWidgets.QVBoxLayout()
133
157
  tree = ParameterTree()
134
158
  # tree.setMinimumWidth(400)
135
159
  # tree.setMinimumHeight(500)
136
160
  tree.setParameters(self.preset_params, showTop=False)
161
+ tree.header().setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)
137
162
 
138
163
  vlayout.addWidget(tree)
139
164
  dialog.setLayout(vlayout)
140
- buttonBox = QtWidgets.QDialogButtonBox(parent=dialog)
165
+ buttonBox = QDialogButtonBox(parent=dialog)
141
166
 
142
- buttonBox.addButton('Save', buttonBox.AcceptRole)
167
+ buttonBox.addButton("Save", QDialogButtonBox.ButtonRole.AcceptRole)
143
168
  buttonBox.accepted.connect(dialog.accept)
144
- buttonBox.addButton('Cancel', buttonBox.RejectRole)
169
+ buttonBox.addButton("Cancel", QDialogButtonBox.ButtonRole.RejectRole)
145
170
  buttonBox.rejected.connect(dialog.reject)
146
171
 
147
172
  vlayout.addWidget(buttonBox)
148
- dialog.setWindowTitle('Fill in information about this manager')
173
+ dialog.setWindowTitle("Fill in information about this manager")
149
174
  res = dialog.exec()
150
175
 
151
176
  path = self.preset_path
152
- file= None
177
+ file = None
153
178
 
154
- if res == dialog.Accepted:
179
+ if res == QDialog.DialogCode.Accepted:
155
180
  # save managers parameters in a xml file
156
181
  # start = os.path.split(os.path.split(os.path.realpath(__file__))[0])[0]
157
182
  # start = os.path.join("..",'daq_scan')
158
183
  filename_without_extension = self.filename
159
184
 
160
185
  try:
161
- ioxml.parameter_to_xml_file(self.preset_params,
162
- path.joinpath(filename_without_extension),
163
- overwrite=False)
186
+ ioxml.parameter_to_xml_file(
187
+ self.preset_params,
188
+ path.joinpath(filename_without_extension),
189
+ overwrite=False,
190
+ )
164
191
  except FileExistsError as currenterror:
165
192
  # logger.warning(str(currenterror)+"File " + filename_without_extension + ".xml exists")
166
- logger.warning(f"{currenterror} File {filename_without_extension}.xml exists")
167
- user_agreed = dialogbox(title='Overwrite confirmation',
168
- message="File exist do you want to overwrite it ?")
193
+ logger.warning(
194
+ f"{currenterror} File {filename_without_extension}.xml exists"
195
+ )
196
+ user_agreed = dialogbox(
197
+ title="Overwrite confirmation",
198
+ message="File exist do you want to overwrite it ?",
199
+ )
169
200
  if user_agreed:
170
- ioxml.parameter_to_xml_file(self.preset_params,
171
- path.joinpath(filename_without_extension))
172
- logger.warning(f"File {filename_without_extension}.xml overwriten at user request")
201
+ ioxml.parameter_to_xml_file(
202
+ self.preset_params, path.joinpath(filename_without_extension)
203
+ )
204
+ logger.warning(
205
+ f"File {filename_without_extension}.xml overwriten at user request"
206
+ )
173
207
  else:
174
- logger.warning(f"File {filename_without_extension}.xml wasn't saved at user request")
208
+ logger.warning(
209
+ f"File {filename_without_extension}.xml wasn't saved at user request"
210
+ )
175
211
  # emit status signal to dashboard to write : did not save ?
176
212
  pass
177
213
 
178
214
  # check if overshoot configuration and layout configuration with same name exists => delete them if yes
179
- over_shoot_file = overshoot_path.joinpath(self.filename + '.xml')
215
+ over_shoot_file = overshoot_path.joinpath(self.filename + ".xml")
180
216
  over_shoot_file.unlink(missing_ok=True)
181
217
 
182
- layout_file = layout_path.joinpath(self.filename + '.dock')
218
+ layout_file = layout_path.joinpath(self.filename + ".dock")
183
219
  layout_file.unlink(missing_ok=True)
184
220
 
185
- return res == dialog.Accepted
221
+ return res == QDialog.DialogCode.Accepted
186
222
 
187
223
 
188
- if __name__ == '__main__':
224
+ if __name__ == "__main__":
189
225
  app = QtWidgets.QApplication(sys.argv)
190
226
  # prog = PresetManager(True)
191
227
  prog = PresetManager(True)