qplotter 1.6.0b3__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.
Files changed (119) hide show
  1. qplot/__init__.py +46 -0
  2. qplot/__main__.py +232 -0
  3. qplot/_auxiliary_paths.py +63 -0
  4. qplot/_metadata.py +12 -0
  5. qplot/_repair.py +14 -0
  6. qplot/_shutdown_supervisor.py +4049 -0
  7. qplot/_version.py +12 -0
  8. qplot/_windows_shutdown_job.py +1166 -0
  9. qplot/configuration/__init__.py +3 -0
  10. qplot/configuration/config.py +573 -0
  11. qplot/configuration/config_schema.json +319 -0
  12. qplot/configuration/scripts.py +255 -0
  13. qplot/configuration/themes/__init__.py +13 -0
  14. qplot/configuration/themes/_base.py +579 -0
  15. qplot/configuration/themes/blank.py +17 -0
  16. qplot/configuration/themes/dark.py +54 -0
  17. qplot/configuration/themes/light.py +54 -0
  18. qplot/datahandling/LoadFromDB.py +224 -0
  19. qplot/datahandling/__init__.py +47 -0
  20. qplot/datahandling/_trusted_live_helper.py +812 -0
  21. qplot/datahandling/_trusted_live_protocol.py +1745 -0
  22. qplot/datahandling/database.py +2330 -0
  23. qplot/datahandling/dimensions.py +43 -0
  24. qplot/datahandling/file_identity.py +461 -0
  25. qplot/datahandling/parameter_data.py +149 -0
  26. qplot/datahandling/plot_progress.py +17 -0
  27. qplot/datahandling/qcodes_cache.py +277 -0
  28. qplot/datahandling/qcodes_compat.py +14 -0
  29. qplot/datahandling/readSQL.py +2442 -0
  30. qplot/datahandling/readonly.py +2561 -0
  31. qplot/datahandling/source_activity.py +21 -0
  32. qplot/datahandling/trusted_array_preview.py +127 -0
  33. qplot/datahandling/trusted_derived_cache.py +1605 -0
  34. qplot/datahandling/trusted_derived_rendering.py +868 -0
  35. qplot/datahandling/trusted_heatmap.py +241 -0
  36. qplot/datahandling/trusted_live.py +2808 -0
  37. qplot/datahandling/trusted_live_queries.py +5907 -0
  38. qplot/datahandling/trusted_live_service.py +1894 -0
  39. qplot/datahandling/trusted_live_supervisor.py +2161 -0
  40. qplot/datahandling/trusted_plot.py +283 -0
  41. qplot/datahandling/trusted_presentation.py +1065 -0
  42. qplot/datahandling/trusted_snapshot.py +1132 -0
  43. qplot/datahandling/trusted_work_coordinator.py +2157 -0
  44. qplot/datahandling/trusted_work_scheduler.py +1204 -0
  45. qplot/diagnostics.py +241 -0
  46. qplot/resources/testdata/qplot_test_db_01_10mb.csv +11 -0
  47. qplot/resources/testdata/qplot_test_db_02_25mb.csv +14 -0
  48. qplot/resources/testdata/qplot_test_db_03_50mb.csv +17 -0
  49. qplot/resources/testdata/qplot_test_db_04_100mb.csv +20 -0
  50. qplot/resources/testdata/qplot_test_db_05_250mb.csv +23 -0
  51. qplot/resources/testdata/qplot_test_db_06_500mb.csv +26 -0
  52. qplot/resources/testdata/qplot_test_db_07_1gb.csv +29 -0
  53. qplot/resources/testdata/qplot_test_db_08_5gb.csv +32 -0
  54. qplot/resources/testdata/qplot_test_db_09_10gb.csv +35 -0
  55. qplot/resources/testdata/qplot_test_db_10_30gb.csv +38 -0
  56. qplot/testdata.py +1733 -0
  57. qplot/tools/__init__.py +13 -0
  58. qplot/tools/finite_means.py +114 -0
  59. qplot/tools/general.py +134 -0
  60. qplot/tools/heatmap_geometry.py +381 -0
  61. qplot/tools/operation_registry.py +179 -0
  62. qplot/tools/plot_tools.py +625 -0
  63. qplot/tools/sample_statistics.py +56 -0
  64. qplot/tools/worker.py +2787 -0
  65. qplot/windows/__init__.py +9 -0
  66. qplot/windows/_colorbar.py +422 -0
  67. qplot/windows/_commands.py +523 -0
  68. qplot/windows/_config_persistence.py +123 -0
  69. qplot/windows/_database_actions.py +4904 -0
  70. qplot/windows/_dataset_handle.py +221 -0
  71. qplot/windows/_dragdrop.py +71 -0
  72. qplot/windows/_export_paths.py +1167 -0
  73. qplot/windows/_help.py +169 -0
  74. qplot/windows/_native_averaging.py +173 -0
  75. qplot/windows/_native_transforms.py +389 -0
  76. qplot/windows/_plot1d_snap.py +608 -0
  77. qplot/windows/_plot1d_traces.py +2183 -0
  78. qplot/windows/_plot2d_colorbar.py +1126 -0
  79. qplot/windows/_plot2d_colorbar_dialog.py +786 -0
  80. qplot/windows/_plot2d_layers.py +2197 -0
  81. qplot/windows/_plot2d_sweeps.py +712 -0
  82. qplot/windows/_plotWin.py +1993 -0
  83. qplot/windows/_plot_actions.py +2695 -0
  84. qplot/windows/_plot_appearance.py +276 -0
  85. qplot/windows/_plot_axis_scaling.py +1485 -0
  86. qplot/windows/_plot_export.py +1445 -0
  87. qplot/windows/_plot_feedback.py +110 -0
  88. qplot/windows/_plot_marquee.py +656 -0
  89. qplot/windows/_plot_refresh.py +942 -0
  90. qplot/windows/_plot_state.py +239 -0
  91. qplot/windows/_plot_transform_labels.py +60 -0
  92. qplot/windows/_preferences.py +635 -0
  93. qplot/windows/_refresh_interval.py +70 -0
  94. qplot/windows/_run_controls.py +828 -0
  95. qplot/windows/_shortcuts.py +47 -0
  96. qplot/windows/_subplots/__init__.py +8 -0
  97. qplot/windows/_subplots/subplot1d.py +531 -0
  98. qplot/windows/_subplots/subplot2d.py +918 -0
  99. qplot/windows/_svg_export.py +209 -0
  100. qplot/windows/_trusted_derived_qt.py +1759 -0
  101. qplot/windows/_widgets/__init__.py +23 -0
  102. qplot/windows/_widgets/_run_formatting.py +387 -0
  103. qplot/windows/_widgets/details_tables.py +1119 -0
  104. qplot/windows/_widgets/dropbox.py +290 -0
  105. qplot/windows/_widgets/operations.py +460 -0
  106. qplot/windows/_widgets/preview.py +2997 -0
  107. qplot/windows/_widgets/run_list_items.py +488 -0
  108. qplot/windows/_widgets/toolbar.py +111 -0
  109. qplot/windows/_widgets/treeWidgets.py +2572 -0
  110. qplot/windows/_window_controls.py +413 -0
  111. qplot/windows/main.py +1635 -0
  112. qplot/windows/plot1d.py +311 -0
  113. qplot/windows/plot2d.py +1901 -0
  114. qplotter-1.6.0b3.dist-info/METADATA +318 -0
  115. qplotter-1.6.0b3.dist-info/RECORD +119 -0
  116. qplotter-1.6.0b3.dist-info/WHEEL +5 -0
  117. qplotter-1.6.0b3.dist-info/entry_points.txt +4 -0
  118. qplotter-1.6.0b3.dist-info/licenses/LICENSE +21 -0
  119. qplotter-1.6.0b3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,290 @@
1
+ from PyQt6 import QtCore
2
+ from PyQt6 import QtWidgets as qtw
3
+ from PyQt6.QtCore import Qt
4
+ from PyQt6.QtGui import QColor
5
+
6
+
7
+ class picker_1d(qtw.QWidget):
8
+ """
9
+ A Custom QWidget that houses widgets for controlling line in plot1d
10
+ Contains 4 interactable widget:
11
+ self.option_box: dropdown menu for user selection
12
+ self.del_box: On click removes line from plot
13
+ self.axis_side: Control which side the plot is attached to (left or right)
14
+ self.color_box: dropdown menu for choosing line colour
15
+
16
+ Uses modified QHBoxLayouts to set context menu on items.
17
+ See qplot.windows._widgets.toolbar.
18
+
19
+ """
20
+ itemSelected = QtCore.pyqtSignal([str])
21
+ closed = QtCore.pyqtSignal([str])
22
+
23
+ del_but_width = 15
24
+ color_box_width = 75
25
+
26
+ def __init__(self, main, cfg, items, *args, item_data=None, **kargs):
27
+ super().__init__()
28
+
29
+ layout = qtw.QVBoxLayout(self)
30
+ layout.setAlignment(Qt.AlignmentFlag.AlignRight)
31
+
32
+ #produce rows with context menu and context manager from dockWidget
33
+ row_1 = main.axes_dock.HBox_context(main.axes_dock.event_filter)
34
+ row_2 = main.axes_dock.HBox_context(main.axes_dock.event_filter)
35
+
36
+ # Selection box
37
+ self.option_box = expandingComboBox(*args, **kargs)
38
+ self.option_box.setSizePolicy(qtw.QSizePolicy.Policy.Expanding, qtw.QSizePolicy.Policy.Fixed)
39
+ self.reset_box(items, item_data=item_data)
40
+ self.option_box.currentIndexChanged.connect(self.selectedOption)
41
+ row_1.addWidget(self.option_box)
42
+
43
+ # Removal box
44
+ self.del_box = qtw.QPushButton("X")
45
+ self.del_box.setFixedWidth(self.del_but_width)
46
+ self.del_box.setToolTip("Remove this line from the plot")
47
+ self.del_box.setDisabled(True)
48
+ self.del_box.clicked.connect(self.deleteBox)
49
+ row_1.addWidget(self.del_box)
50
+
51
+
52
+ row_2.addWidget(qtw.QLabel("Side: "))
53
+
54
+ # Axis side picker
55
+ self.axis_side = expandingComboBox()
56
+ self.axis_side.addItems(["Left", "Right"])
57
+ self.axis_side.setCurrentIndex(0)
58
+ row_2.addWidget(self.axis_side)
59
+
60
+ row_2.addStretch()
61
+ row_2.addWidget(qtw.QLabel("Color: "))
62
+
63
+ # Line colour picker
64
+ self.color_box = colorBox(cfg)
65
+ self.color_box.setFixedWidth(self.color_box_width)
66
+ row_2.addWidget(self.color_box)
67
+
68
+ layout.addLayout(row_1)
69
+ layout.addLayout(row_2)
70
+
71
+
72
+ def reset_box(self, items, item_data=None):
73
+ """
74
+ Resets the widget to default and sets selectable items
75
+
76
+ Parameters
77
+ ----------
78
+ items : list[str]
79
+ List of items that the user can select from
80
+ item_data : list[object], optional
81
+ Stable internal identities corresponding to ``items``. When omitted,
82
+ the displayed text is also used as the identity.
83
+
84
+ """
85
+ self.option_box.blockSignals(True)
86
+
87
+ # Reset selection
88
+ self.option_box.clear()
89
+ if items:
90
+ identities = items if item_data is None else item_data
91
+ for label, identity in zip(items, identities, strict=True):
92
+ self.option_box.addItem(label, userData=identity)
93
+
94
+ # Reset display
95
+ self.option_box.setEditable(True)
96
+ line_edit = self.option_box.lineEdit()
97
+ if line_edit is not None:
98
+ line_edit.setReadOnly(True)
99
+ line_edit.setPlaceholderText("Add to Plot")
100
+ self.option_box.setCurrentIndex(-1) # set to placeholder
101
+
102
+ self.option_box.blockSignals(False)
103
+
104
+
105
+ @QtCore.pyqtSlot(int)
106
+ def selectedOption(self, index):
107
+ """
108
+ Event handler for selecting a option in self.option_box
109
+
110
+ Parameters
111
+ ----------
112
+ Unused but required by slot
113
+
114
+ """
115
+ self.option_box.setDisabled(True)
116
+ self.del_box.setEnabled(True)
117
+
118
+ # Find text width
119
+ view = self.option_box.view()
120
+ font_metrics = view.fontMetrics() if view is not None else self.option_box.fontMetrics()
121
+ text_width = font_metrics.boundingRect(self.option_box.currentText()).width()
122
+
123
+ # Set width with small pad, ScrollArea which is placed in struggles to
124
+ # correctly fetch width when only 1 option
125
+ self.option_box.setMinimumWidth(text_width + 10)
126
+
127
+ # Emit to plot1d for further handling
128
+ self.itemSelected.emit(self.option_box.currentText())
129
+
130
+
131
+ @QtCore.pyqtSlot()
132
+ def deleteBox(self):
133
+ """
134
+ Event handler for del_box pressed
135
+ Removes widget.
136
+
137
+ """
138
+ # Removal
139
+ self.setParent(None)
140
+ self.deleteLater()
141
+
142
+ # Emit to plot1d for further handling
143
+ self.closed.emit(self.option_box.currentText())
144
+
145
+
146
+ class expandingComboBox(qtw.QComboBox):
147
+ """
148
+ A custom QComboBox which allows dropdown options to be larger than ComboBox
149
+
150
+ """
151
+ def showPopup(self):
152
+ view = self.view()
153
+ if view is None:
154
+ super().showPopup()
155
+ return
156
+
157
+ # Get width of largest item in options
158
+ max_width = 0
159
+ font_metrics = view.fontMetrics()
160
+ for i in range(self.count()):
161
+ text_width = font_metrics.boundingRect(self.itemText(i)).width()
162
+ max_width = max(max_width, text_width)
163
+
164
+ max_width += 5
165
+
166
+ # Update width
167
+ view.setMinimumWidth(max_width)
168
+
169
+ # Display options
170
+ super().showPopup()
171
+
172
+ def wheelEvent(self, event):
173
+ """
174
+ Prevents scrolling on box as it can cause accidental selection, by
175
+ prevent ignoring signal.
176
+
177
+ Parameters
178
+ ----------
179
+ event : PyQt6.<something?>.QGraphicsSceneWheelEvent
180
+
181
+ """
182
+ event.ignore()
183
+
184
+ class colorBox(qtw.QComboBox):
185
+ """
186
+ A Custom QComboBox which can display colour options and emit those colours
187
+ through signals.
188
+
189
+ """
190
+ selectedColor = QtCore.pyqtSignal([QColor])
191
+
192
+ def __init__(self, cfg, *args, **kargs):
193
+ super().__init__(*args, **kargs)
194
+
195
+ # Required to allow changes but prevent user typing
196
+ self.setEditable(True)
197
+ line_edit = self.lineEdit()
198
+ if line_edit is not None:
199
+ line_edit.setReadOnly(True)
200
+
201
+ self.activated.connect(self._color_selected)
202
+
203
+ # Get options from config.themes
204
+ for col in cfg.theme.colors:
205
+ self.addItem('', userData = col)
206
+ self.setItemData(self.count()-1, col, Qt.ItemDataRole.BackgroundRole)
207
+ self.addItem('Custom')
208
+
209
+
210
+ def color(self):
211
+ """
212
+ Returns the currently select color
213
+
214
+ Returns
215
+ -------
216
+ PyQt6.QtGui.QColor
217
+ Returns the currently select color.
218
+
219
+ """
220
+ return self._currentColor
221
+
222
+
223
+ def setColor(self, color):
224
+ """
225
+ Sets color to selected color
226
+
227
+ Parameters
228
+ ----------
229
+ color : PyQt6.QtGui.QColor
230
+ Color to display.
231
+
232
+ """
233
+ self._color_selected(color=color, emitSignal=False)
234
+
235
+
236
+ @QtCore.pyqtSlot(int)
237
+ def _color_selected(self, index = None, color = None, emitSignal = True):
238
+ """
239
+ Event handler for selecting an option
240
+
241
+ Parameters
242
+ ----------
243
+ index : int, optional
244
+ The index of the selection from the options.
245
+ color : PyQt6.QtGui.QColor, optional
246
+ Force override to a specific color. The default is None.
247
+ emitSignal : bool, optional
248
+ Whether to emit a signal to main. The default is True.
249
+
250
+ """
251
+ # Allow user to select a custom colour
252
+ if index and self.itemText(index) == "Custom":
253
+ self.setCurrentText("")
254
+ color = qtw.QColorDialog.getColor()
255
+
256
+ # Check user did note exit out
257
+ if not color.isValid():
258
+ return
259
+
260
+ self._currentColor = color
261
+
262
+ # Force setting a color
263
+ elif color:
264
+ self._currentColor = color
265
+
266
+ # Select from preset colours
267
+ else:
268
+ self._currentColor = self.itemData(index)
269
+ self.setCurrentIndex(self.findData(self._currentColor))
270
+
271
+ # Update visual display of dropdown
272
+ line_edit = self.lineEdit()
273
+ if line_edit is not None:
274
+ line_edit.setStyleSheet("background-color: " + self._currentColor.name())
275
+ # Emit signal to main for further handling
276
+ if emitSignal:
277
+ self.selectedColor.emit(self._currentColor)
278
+
279
+
280
+ def wheelEvent(self, event):
281
+ """
282
+ Prevents scrolling on box as it can cause accidental selection, by
283
+ prevent ignoring signal.
284
+
285
+ Parameters
286
+ ----------
287
+ event : PyQt6.<something?>.QGraphicsSceneWheelEvent
288
+
289
+ """
290
+ event.ignore()