bec-widgets 1.23.1__py3-none-any.whl → 1.24.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.
@@ -6,245 +6,201 @@
6
6
  <rect>
7
7
  <x>0</x>
8
8
  <y>0</y>
9
- <width>427</width>
10
- <height>270</height>
9
+ <width>486</width>
10
+ <height>300</height>
11
11
  </rect>
12
12
  </property>
13
- <property name="minimumSize">
14
- <size>
15
- <width>0</width>
16
- <height>250</height>
17
- </size>
18
- </property>
19
- <property name="maximumSize">
20
- <size>
21
- <width>16777215</width>
22
- <height>278</height>
23
- </size>
24
- </property>
25
13
  <property name="windowTitle">
26
14
  <string>Form</string>
27
15
  </property>
28
16
  <layout class="QGridLayout" name="gridLayout">
29
- <item row="0" column="0" colspan="2">
30
- <layout class="QHBoxLayout" name="horizontalLayout">
31
- <item>
32
- <widget class="QLabel" name="plot_title_label">
33
- <property name="text">
34
- <string>Plot Title</string>
35
- </property>
36
- </widget>
37
- </item>
38
- <item>
39
- <widget class="QLineEdit" name="plot_title"/>
40
- </item>
41
- </layout>
42
- </item>
43
17
  <item row="1" column="0">
18
+ <widget class="QLabel" name="label">
19
+ <property name="text">
20
+ <string>Inner Axes</string>
21
+ </property>
22
+ </widget>
23
+ </item>
24
+ <item row="1" column="1">
25
+ <widget class="ToggleSwitch" name="inner_axes"/>
26
+ </item>
27
+ <item row="1" column="2">
44
28
  <widget class="QLabel" name="label_outer_axes">
45
29
  <property name="text">
46
30
  <string>Outer Axes</string>
47
31
  </property>
48
32
  </widget>
49
33
  </item>
50
- <item row="2" column="1">
51
- <widget class="QGroupBox" name="y_axis_box">
34
+ <item row="1" column="3">
35
+ <widget class="ToggleSwitch" name="outer_axes">
36
+ <property name="checked" stdset="0">
37
+ <bool>false</bool>
38
+ </property>
39
+ </widget>
40
+ </item>
41
+ <item row="2" column="0" colspan="2">
42
+ <widget class="QGroupBox" name="x_axis_box">
52
43
  <property name="title">
53
- <string>Y Axis</string>
44
+ <string>X Axis</string>
54
45
  </property>
55
- <layout class="QGridLayout" name="gridLayout_5">
56
- <item row="3" column="2">
57
- <widget class="QComboBox" name="y_scale">
58
- <item>
59
- <property name="text">
60
- <string>linear</string>
61
- </property>
62
- </item>
63
- <item>
64
- <property name="text">
65
- <string>log</string>
66
- </property>
67
- </item>
46
+ <layout class="QGridLayout" name="gridLayout_4">
47
+ <item row="5" column="0">
48
+ <widget class="QLabel" name="x_grid_label">
49
+ <property name="text">
50
+ <string>Grid</string>
51
+ </property>
68
52
  </widget>
69
53
  </item>
70
- <item row="2" column="2">
71
- <widget class="QDoubleSpinBox" name="y_max">
72
- <property name="alignment">
73
- <set>Qt::AlignmentFlag::AlignCenter</set>
74
- </property>
75
- <property name="minimum">
76
- <double>-9999.000000000000000</double>
77
- </property>
78
- <property name="maximum">
79
- <double>9999.000000000000000</double>
54
+ <item row="3" column="2">
55
+ <widget class="ToggleSwitch" name="x_log">
56
+ <property name="checked" stdset="0">
57
+ <bool>false</bool>
80
58
  </property>
81
59
  </widget>
82
60
  </item>
83
- <item row="1" column="0" colspan="2">
84
- <widget class="QLabel" name="y_min_label">
61
+ <item row="2" column="0">
62
+ <widget class="QLabel" name="x_max_label">
85
63
  <property name="text">
86
- <string>Min</string>
64
+ <string>Max</string>
87
65
  </property>
88
66
  </widget>
89
67
  </item>
90
- <item row="1" column="2">
91
- <widget class="QDoubleSpinBox" name="y_min">
92
- <property name="alignment">
93
- <set>Qt::AlignmentFlag::AlignCenter</set>
94
- </property>
95
- <property name="minimum">
96
- <double>-9999.000000000000000</double>
97
- </property>
98
- <property name="maximum">
99
- <double>9999.000000000000000</double>
68
+ <item row="5" column="2">
69
+ <widget class="ToggleSwitch" name="x_grid">
70
+ <property name="checked" stdset="0">
71
+ <bool>false</bool>
100
72
  </property>
101
73
  </widget>
102
74
  </item>
103
- <item row="0" column="2">
104
- <widget class="QLineEdit" name="y_label"/>
105
- </item>
106
75
  <item row="3" column="0">
107
- <widget class="QLabel" name="y_scale_label">
76
+ <widget class="QLabel" name="x_scale_label">
108
77
  <property name="text">
109
- <string>Scale</string>
78
+ <string>Log</string>
110
79
  </property>
111
80
  </widget>
112
81
  </item>
113
- <item row="0" column="0">
114
- <widget class="QLabel" name="y_label_label">
82
+ <item row="1" column="0" colspan="2">
83
+ <widget class="QLabel" name="x_min_label">
115
84
  <property name="text">
116
- <string>Label</string>
85
+ <string>Min</string>
117
86
  </property>
118
87
  </widget>
119
88
  </item>
120
- <item row="2" column="0">
121
- <widget class="QLabel" name="y_max_label">
89
+ <item row="0" column="0">
90
+ <widget class="QLabel" name="x_label_label">
122
91
  <property name="text">
123
- <string>Max</string>
92
+ <string>Label</string>
124
93
  </property>
125
94
  </widget>
126
95
  </item>
127
- <item row="4" column="2">
128
- <widget class="QCheckBox" name="y_grid">
129
- <property name="text">
130
- <string/>
131
- </property>
132
- </widget>
96
+ <item row="0" column="2">
97
+ <widget class="QLineEdit" name="x_label"/>
133
98
  </item>
134
- <item row="4" column="0">
135
- <widget class="QLabel" name="y_grid_label">
136
- <property name="text">
137
- <string>Grid</string>
138
- </property>
139
- </widget>
99
+ <item row="1" column="2">
100
+ <widget class="BECSpinBox" name="x_min"/>
101
+ </item>
102
+ <item row="2" column="2">
103
+ <widget class="BECSpinBox" name="x_max"/>
140
104
  </item>
141
105
  </layout>
142
106
  </widget>
143
107
  </item>
144
- <item row="2" column="0">
145
- <widget class="QGroupBox" name="x_axis_box">
108
+ <item row="2" column="2" colspan="2">
109
+ <widget class="QGroupBox" name="y_axis_box">
146
110
  <property name="title">
147
- <string>X Axis</string>
111
+ <string>Y Axis</string>
148
112
  </property>
149
- <layout class="QGridLayout" name="gridLayout_4">
150
- <item row="3" column="0">
151
- <widget class="QLabel" name="x_scale_label">
113
+ <layout class="QGridLayout" name="gridLayout_5">
114
+ <item row="1" column="0" colspan="2">
115
+ <widget class="QLabel" name="y_min_label">
152
116
  <property name="text">
153
- <string>Scale</string>
117
+ <string>Min</string>
154
118
  </property>
155
119
  </widget>
156
120
  </item>
157
- <item row="1" column="2">
158
- <widget class="QDoubleSpinBox" name="x_min">
159
- <property name="alignment">
160
- <set>Qt::AlignmentFlag::AlignCenter</set>
161
- </property>
162
- <property name="minimum">
163
- <double>-9999.000000000000000</double>
164
- </property>
165
- <property name="maximum">
166
- <double>9999.000000000000000</double>
167
- </property>
168
- </widget>
121
+ <item row="0" column="2">
122
+ <widget class="QLineEdit" name="y_label"/>
169
123
  </item>
170
- <item row="1" column="0" colspan="2">
171
- <widget class="QLabel" name="x_min_label">
124
+ <item row="3" column="0">
125
+ <widget class="QLabel" name="y_scale_label">
172
126
  <property name="text">
173
- <string>Min</string>
127
+ <string>Log</string>
174
128
  </property>
175
129
  </widget>
176
130
  </item>
177
- <item row="2" column="2">
178
- <widget class="QDoubleSpinBox" name="x_max">
179
- <property name="alignment">
180
- <set>Qt::AlignmentFlag::AlignCenter</set>
181
- </property>
182
- <property name="minimum">
183
- <double>-9999.000000000000000</double>
184
- </property>
185
- <property name="maximum">
186
- <double>9999.000000000000000</double>
131
+ <item row="0" column="0">
132
+ <widget class="QLabel" name="y_label_label">
133
+ <property name="text">
134
+ <string>Label</string>
187
135
  </property>
188
136
  </widget>
189
137
  </item>
190
- <item row="3" column="2">
191
- <widget class="QComboBox" name="x_scale">
192
- <item>
193
- <property name="text">
194
- <string>linear</string>
195
- </property>
196
- </item>
197
- <item>
198
- <property name="text">
199
- <string>log</string>
200
- </property>
201
- </item>
202
- </widget>
203
- </item>
204
138
  <item row="2" column="0">
205
- <widget class="QLabel" name="x_max_label">
139
+ <widget class="QLabel" name="y_max_label">
206
140
  <property name="text">
207
141
  <string>Max</string>
208
142
  </property>
209
143
  </widget>
210
144
  </item>
211
- <item row="0" column="2">
212
- <widget class="QLineEdit" name="x_label"/>
213
- </item>
214
- <item row="0" column="0">
215
- <widget class="QLabel" name="x_label_label">
145
+ <item row="4" column="0">
146
+ <widget class="QLabel" name="y_grid_label">
216
147
  <property name="text">
217
- <string>Label</string>
148
+ <string>Grid</string>
149
+ </property>
150
+ </widget>
151
+ </item>
152
+ <item row="3" column="2">
153
+ <widget class="ToggleSwitch" name="y_log">
154
+ <property name="checked" stdset="0">
155
+ <bool>false</bool>
218
156
  </property>
219
157
  </widget>
220
158
  </item>
221
159
  <item row="4" column="2">
222
- <widget class="QCheckBox" name="x_grid">
223
- <property name="text">
224
- <string/>
160
+ <widget class="ToggleSwitch" name="y_grid">
161
+ <property name="checked" stdset="0">
162
+ <bool>false</bool>
225
163
  </property>
226
164
  </widget>
227
165
  </item>
228
- <item row="4" column="0">
229
- <widget class="QLabel" name="x_grid_label">
230
- <property name="text">
231
- <string>Grid</string>
166
+ <item row="1" column="2">
167
+ <widget class="BECSpinBox" name="y_min">
168
+ <property name="alignment">
169
+ <set>Qt::AlignmentFlag::AlignCenter</set>
170
+ </property>
171
+ <property name="buttonSymbols">
172
+ <enum>QAbstractSpinBox::ButtonSymbols::UpDownArrows</enum>
232
173
  </property>
233
174
  </widget>
234
175
  </item>
176
+ <item row="2" column="2">
177
+ <widget class="BECSpinBox" name="y_max"/>
178
+ </item>
235
179
  </layout>
236
180
  </widget>
237
181
  </item>
238
- <item row="1" column="1">
239
- <widget class="ToggleSwitch" name="switch_outer_axes">
240
- <property name="checked" stdset="0">
241
- <bool>false</bool>
242
- </property>
243
- </widget>
182
+ <item row="0" column="0" colspan="4">
183
+ <layout class="QHBoxLayout" name="horizontalLayout">
184
+ <item>
185
+ <widget class="QLabel" name="plot_title_label">
186
+ <property name="text">
187
+ <string>Plot Title</string>
188
+ </property>
189
+ </widget>
190
+ </item>
191
+ <item>
192
+ <widget class="QLineEdit" name="title"/>
193
+ </item>
194
+ </layout>
244
195
  </item>
245
196
  </layout>
246
197
  </widget>
247
198
  <customwidgets>
199
+ <customwidget>
200
+ <class>BECSpinBox</class>
201
+ <extends>QDoubleSpinBox</extends>
202
+ <header>bec_spin_box</header>
203
+ </customwidget>
248
204
  <customwidget>
249
205
  <class>ToggleSwitch</class>
250
206
  <extends>QWidget</extends>
@@ -20,19 +20,6 @@
20
20
  <string>X Axis</string>
21
21
  </property>
22
22
  <layout class="QGridLayout" name="gridLayout_4">
23
- <item row="2" column="2">
24
- <widget class="QDoubleSpinBox" name="x_max">
25
- <property name="alignment">
26
- <set>Qt::AlignmentFlag::AlignCenter</set>
27
- </property>
28
- <property name="minimum">
29
- <double>-9999.000000000000000</double>
30
- </property>
31
- <property name="maximum">
32
- <double>9999.000000000000000</double>
33
- </property>
34
- </widget>
35
- </item>
36
23
  <item row="3" column="0">
37
24
  <widget class="QLabel" name="x_scale_label">
38
25
  <property name="text">
@@ -64,19 +51,6 @@
64
51
  </property>
65
52
  </widget>
66
53
  </item>
67
- <item row="1" column="2">
68
- <widget class="QDoubleSpinBox" name="x_min">
69
- <property name="alignment">
70
- <set>Qt::AlignmentFlag::AlignCenter</set>
71
- </property>
72
- <property name="minimum">
73
- <double>-9999.000000000000000</double>
74
- </property>
75
- <property name="maximum">
76
- <double>9999.000000000000000</double>
77
- </property>
78
- </widget>
79
- </item>
80
54
  <item row="1" column="0" colspan="2">
81
55
  <widget class="QLabel" name="x_min_label">
82
56
  <property name="text">
@@ -98,6 +72,12 @@
98
72
  </property>
99
73
  </widget>
100
74
  </item>
75
+ <item row="1" column="2">
76
+ <widget class="BECSpinBox" name="x_min"/>
77
+ </item>
78
+ <item row="2" column="2">
79
+ <widget class="BECSpinBox" name="x_max"/>
80
+ </item>
101
81
  </layout>
102
82
  </widget>
103
83
  </item>
@@ -128,19 +108,6 @@
128
108
  <string>Y Axis</string>
129
109
  </property>
130
110
  <layout class="QGridLayout" name="gridLayout_5">
131
- <item row="2" column="2">
132
- <widget class="QDoubleSpinBox" name="y_max">
133
- <property name="alignment">
134
- <set>Qt::AlignmentFlag::AlignCenter</set>
135
- </property>
136
- <property name="minimum">
137
- <double>-9999.000000000000000</double>
138
- </property>
139
- <property name="maximum">
140
- <double>9999.000000000000000</double>
141
- </property>
142
- </widget>
143
- </item>
144
111
  <item row="1" column="0" colspan="2">
145
112
  <widget class="QLabel" name="y_min_label">
146
113
  <property name="text">
@@ -148,19 +115,6 @@
148
115
  </property>
149
116
  </widget>
150
117
  </item>
151
- <item row="1" column="2">
152
- <widget class="QDoubleSpinBox" name="y_min">
153
- <property name="alignment">
154
- <set>Qt::AlignmentFlag::AlignCenter</set>
155
- </property>
156
- <property name="minimum">
157
- <double>-9999.000000000000000</double>
158
- </property>
159
- <property name="maximum">
160
- <double>9999.000000000000000</double>
161
- </property>
162
- </widget>
163
- </item>
164
118
  <item row="0" column="2">
165
119
  <widget class="QLineEdit" name="y_label"/>
166
120
  </item>
@@ -206,6 +160,12 @@
206
160
  </property>
207
161
  </widget>
208
162
  </item>
163
+ <item row="1" column="2">
164
+ <widget class="BECSpinBox" name="y_min"/>
165
+ </item>
166
+ <item row="2" column="2">
167
+ <widget class="BECSpinBox" name="y_max"/>
168
+ </item>
209
169
  </layout>
210
170
  </widget>
211
171
  </item>
@@ -229,6 +189,11 @@
229
189
  </layout>
230
190
  </widget>
231
191
  <customwidgets>
192
+ <customwidget>
193
+ <class>BECSpinBox</class>
194
+ <extends>QDoubleSpinBox</extends>
195
+ <header>bec_spin_box</header>
196
+ </customwidget>
232
197
  <customwidget>
233
198
  <class>ToggleSwitch</class>
234
199
  <extends>QWidget</extends>
@@ -1,7 +1,8 @@
1
1
  import pyqtgraph as pg
2
+ from qtpy.QtCore import QTimer
2
3
 
3
4
  from bec_widgets.qt_utils.error_popups import SafeSlot
4
- from bec_widgets.qt_utils.toolbar import MaterialIconAction, ToolbarBundle
5
+ from bec_widgets.qt_utils.toolbar import MaterialIconAction, SwitchableToolBarAction, ToolbarBundle
5
6
 
6
7
 
7
8
  class MouseInteractionToolbarBundle(ToolbarBundle):
@@ -15,6 +16,7 @@ class MouseInteractionToolbarBundle(ToolbarBundle):
15
16
  def __init__(self, bundle_id="mouse_interaction", target_widget=None, **kwargs):
16
17
  super().__init__(bundle_id=bundle_id, actions=[], **kwargs)
17
18
  self.target_widget = target_widget
19
+ self.mouse_mode = None
18
20
 
19
21
  # Create each MaterialIconAction with a parent
20
22
  # so the signals can fire even if the toolbar isn't added yet.
@@ -43,9 +45,16 @@ class MouseInteractionToolbarBundle(ToolbarBundle):
43
45
  parent=self.target_widget,
44
46
  )
45
47
 
48
+ self.switch_mouse_action = SwitchableToolBarAction(
49
+ actions={"drag_mode": drag, "rectangle_mode": rect},
50
+ initial_action="drag_mode",
51
+ tooltip="Mouse Modes",
52
+ checkable=True,
53
+ parent=self,
54
+ )
55
+
46
56
  # Add them to the bundle
47
- self.add_action("drag_mode", drag)
48
- self.add_action("rectangle_mode", rect)
57
+ self.add_action("switch_mouse", self.switch_mouse_action)
49
58
  self.add_action("auto_range", auto)
50
59
  self.add_action("aspect_ratio", aspect_ratio)
51
60
 
@@ -55,33 +64,34 @@ class MouseInteractionToolbarBundle(ToolbarBundle):
55
64
  auto.action.triggered.connect(self.autorange_plot)
56
65
  aspect_ratio.action.toggled.connect(self.lock_aspect_ratio)
57
66
 
58
- mode = self.get_viewbox_mode()
59
- if mode == "PanMode":
60
- drag.action.setChecked(True)
61
- elif mode == "RectMode":
62
- rect.action.setChecked(True)
67
+ # Give some time to check the state
68
+ QTimer.singleShot(10, self.get_viewbox_mode)
63
69
 
64
- def get_viewbox_mode(self) -> str:
70
+ def get_viewbox_mode(self):
65
71
  """
66
- Returns the current interaction mode of a PyQtGraph ViewBox.
67
-
68
- Returns:
69
- str: "PanMode" if pan is enabled, "RectMode" if zoom is enabled, "Unknown" otherwise.
72
+ Returns the current interaction mode of a PyQtGraph ViewBox and sets the corresponding action.
70
73
  """
74
+
71
75
  if self.target_widget:
72
76
  viewbox = self.target_widget.plot_item.getViewBox()
73
77
  if viewbox.getState()["mouseMode"] == 3:
74
- return "PanMode"
78
+ self.switch_mouse_action.set_default_action("drag_mode")
79
+ self.switch_mouse_action.main_button.setChecked(True)
80
+ self.mouse_mode = "PanMode"
75
81
  elif viewbox.getState()["mouseMode"] == 1:
76
- return "RectMode"
77
- return "Unknown"
82
+ self.switch_mouse_action.set_default_action("rectangle_mode")
83
+ self.switch_mouse_action.main_button.setChecked(True)
84
+ self.mouse_mode = "RectMode"
78
85
 
79
86
  @SafeSlot(bool)
80
87
  def enable_mouse_rectangle_mode(self, checked: bool):
81
88
  """
82
89
  Enable the rectangle zoom mode on the plot widget.
83
90
  """
84
- self.actions["drag_mode"].action.setChecked(not checked)
91
+ if self.mouse_mode == "RectMode":
92
+ self.switch_mouse_action.main_button.setChecked(True)
93
+ return
94
+ self.actions["switch_mouse"].actions["drag_mode"].action.setChecked(not checked)
85
95
  if self.target_widget and checked:
86
96
  self.target_widget.plot_item.getViewBox().setMouseMode(pg.ViewBox.RectMode)
87
97
 
@@ -90,7 +100,10 @@ class MouseInteractionToolbarBundle(ToolbarBundle):
90
100
  """
91
101
  Enable the pan mode on the plot widget.
92
102
  """
93
- self.actions["rectangle_mode"].action.setChecked(not checked)
103
+ if self.mouse_mode == "PanMode":
104
+ self.switch_mouse_action.main_button.setChecked(True)
105
+ return
106
+ self.actions["switch_mouse"].actions["rectangle_mode"].action.setChecked(not checked)
94
107
  if self.target_widget and checked:
95
108
  self.target_widget.plot_item.getViewBox().setMouseMode(pg.ViewBox.PanMode)
96
109
 
@@ -1,7 +1,7 @@
1
1
  from pyqtgraph.exporters import MatplotlibExporter
2
2
 
3
3
  from bec_widgets.qt_utils.error_popups import SafeSlot, WarningPopupUtility
4
- from bec_widgets.qt_utils.toolbar import MaterialIconAction, ToolbarBundle
4
+ from bec_widgets.qt_utils.toolbar import MaterialIconAction, SwitchableToolBarAction, ToolbarBundle
5
5
 
6
6
 
7
7
  class PlotExportBundle(ToolbarBundle):
@@ -25,9 +25,16 @@ class PlotExportBundle(ToolbarBundle):
25
25
  icon_name="photo_library", tooltip="Open Matplotlib Dialog", parent=self.target_widget
26
26
  )
27
27
 
28
+ switch_export_action = SwitchableToolBarAction(
29
+ actions={"save": save, "matplotlib": matplotlib},
30
+ initial_action="save",
31
+ tooltip="Switchable Action",
32
+ checkable=False,
33
+ parent=self,
34
+ )
35
+
28
36
  # Add them to the bundle
29
- self.add_action("save", save)
30
- self.add_action("matplotlib", matplotlib)
37
+ self.add_action("export_switch", switch_export_action)
31
38
 
32
39
  # Immediately connect signals
33
40
  save.action.triggered.connect(self.export_dialog)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bec_widgets
3
- Version: 1.23.1
3
+ Version: 1.24.1
4
4
  Summary: BEC Widgets
5
5
  Project-URL: Bug Tracker, https://gitlab.psi.ch/bec/bec_widgets/issues
6
6
  Project-URL: Homepage, https://gitlab.psi.ch/bec/bec_widgets