bec-widgets 0.101.0__py3-none-any.whl → 0.103.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.
.gitlab-ci.yml CHANGED
@@ -5,8 +5,12 @@ image: $CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX/python:3.11
5
5
  #commands to run in the Docker container before starting each job.
6
6
  variables:
7
7
  DOCKER_TLS_CERTDIR: ""
8
- BEC_CORE_BRANCH: "main"
9
- OPHYD_DEVICES_BRANCH: "main"
8
+ BEC_CORE_BRANCH:
9
+ description: bec branch
10
+ value: main
11
+ OPHYD_DEVICES_BRANCH:
12
+ description: ophyd_devices branch
13
+ value: main
10
14
  CHILD_PIPELINE_BRANCH: $CI_DEFAULT_BRANCH
11
15
 
12
16
  workflow:
CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v0.103.0 (2024-09-04)
4
+
5
+ ### Ci
6
+
7
+ * ci: prefill variables for manual pipeline start ([`158c19e`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/158c19eda771562a325fd59405f9fd4cb9a17ed6))
8
+
9
+ ### Feature
10
+
11
+ * feat(vscode): open vscode on a free port ([`52da835`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/52da835803f2453096a8b7df23bee5fdf93ae2bb))
12
+
13
+ * feat(website): added method to wait until the webpage is loaded ([`9be19d4`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/9be19d4abebad08c5fc6bea936dd97475fe8f628))
14
+
15
+ ### Fix
16
+
17
+ * fix(theme): fixed segfault for webengineview for auto updates ([`9866075`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/9866075100577948755b563dc7b7dc4cdc60d040))
18
+
19
+ ### Test
20
+
21
+ * test(webview): fixed tests after refactoring ([`d5eb30c`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/d5eb30cd7df4cb0dc3275dd362768afc211eaf2d))
22
+
23
+ * test(vscode): popen call does not have to be the only one ([`39f98ec`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/39f98ec223ba8b59e478ac788c08c59ffe886b4e))
24
+
25
+ ## v0.102.0 (2024-09-04)
26
+
27
+ ### Documentation
28
+
29
+ * docs(buttons): buttons section of docs split to appearance and queue buttons ([`047aa26`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/047aa26a60220c826cc1375cf81daf11d1f3ab5c))
30
+
31
+ * docs(tests): added tests tutorial for widget ([`18d8561`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/18d8561c965d149a7662085f7dbe2a39a8c4a475))
32
+
33
+ ### Feature
34
+
35
+ * feat(queue): BECQueue controls extended with Resume, Stop, Abort, Reset buttons ([`0d7c10e`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/0d7c10e670e4937787e1afaa19ca8259ac752486))
36
+
37
+ ### Fix
38
+
39
+ * fix(queue_reset_button): queue reset has to be confirmed with msgBox ([`9dd43aa`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/9dd43aa1fd3991368002605df4389a7a7271011b))
40
+
41
+ ### Refactor
42
+
43
+ * refactor(tests): positioner box test changed to use create_widget fixture ([`df5eff3`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/df5eff3147c79ff0278e6a5a09c8f73d5236aed3))
44
+
3
45
  ## v0.101.0 (2024-09-02)
4
46
 
5
47
  ### Feature
@@ -110,46 +152,6 @@
110
152
 
111
153
  ## v0.99.6 (2024-08-28)
112
154
 
113
- ### Documentation
114
-
115
- * docs: various bugs fixed ([`c31e9a3`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/c31e9a3aff3ee8e984674dee0965ee7f1b6e2b8f))
116
-
117
155
  ### Fix
118
156
 
119
157
  * fix(toolbar): use of native qt separators ([`09c6c93`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/09c6c93c397ce4a21c293f6c79106c74b2db65ca))
120
-
121
- ## v0.99.5 (2024-08-28)
122
-
123
- ### Documentation
124
-
125
- * docs(index): index page is centered ([`02239de`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/02239de0a36fcd6cbf97990b0dec1ddf7ecf6ba6))
126
-
127
- ### Fix
128
-
129
- * fix(dock_area): dark button added ([`e6f204b`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/e6f204b6aa295747a68769f43af2e549149b401a))
130
-
131
- ## v0.99.4 (2024-08-28)
132
-
133
- ### Documentation
134
-
135
- * docs(buttons): added missing buttons docs ([`4e5520a`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/4e5520aee2115d2fc0cebb3865433478a5ec8253))
136
-
137
- * docs(developer): tutorial for BECWidget base class ([`ac2cb51`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/ac2cb5197deef4d51e26ee5beb070eba3ffc210d))
138
-
139
- ### Fix
140
-
141
- * fix(theme): apply theme to all pyqtgraph widgets on manual updates ([`c550186`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/c5501860e8e07a53f4bce144d44ed39eda6290ef))
142
-
143
- ### Refactor
144
-
145
- * refactor(buttons): changed grid and thumbnail fig in gallery ([`4591ba8`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/4591ba8f73e22aba7258cad93c073f1387cb74a0))
146
-
147
- * refactor(icons): removed toolbar icons from assets ([`f335763`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/f335763280adb1d83ba31f073ce206e4cb5d15ef))
148
-
149
- * refactor(icons): moved widget icons to class attribute ICON_NAME ([`e890091`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/e890091d862e42317c7a54fc414ba37c85f268b0))
150
-
151
- ## v0.99.3 (2024-08-27)
152
-
153
- ### Build
154
-
155
- * build: updated min version of bec qthemes ([`d482434`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/d48243483ef8228cc5eb85e40a6b8f5da3b45520))
PKG-INFO CHANGED
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: bec_widgets
3
- Version: 0.101.0
3
+ Version: 0.103.0
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
@@ -162,6 +162,7 @@ class WidgetAction(ToolBarAction):
162
162
  def add_to_toolbar(self, toolbar, target):
163
163
  widget = QWidget()
164
164
  layout = QHBoxLayout(widget)
165
+ layout.setContentsMargins(0, 0, 0, 0)
165
166
  if self.label is not None:
166
167
  label = QLabel(f"{self.label}")
167
168
  layout.addWidget(label)
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import darkdetect
3
4
  from qtpy.QtCore import Slot
4
5
  from qtpy.QtWidgets import QApplication, QWidget
5
6
 
@@ -45,7 +46,12 @@ class BECWidget(BECConnector):
45
46
  # Set the theme to auto if it is not set yet
46
47
  app = QApplication.instance()
47
48
  if not hasattr(app, "theme"):
48
- set_theme("auto")
49
+ # DO NOT SET THE THEME TO AUTO! Otherwise, the qwebengineview will segfault
50
+ # Instead, we will set the theme to the system setting on startup
51
+ if darkdetect.isDark():
52
+ set_theme("dark")
53
+ else:
54
+ set_theme("light")
49
55
 
50
56
  if theme_update:
51
57
  self._connect_to_theme_change()
@@ -1,11 +1,18 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from bec_lib.endpoints import MessageEndpoints
4
- from qtpy.QtCore import Qt, Slot
5
- from qtpy.QtWidgets import QHBoxLayout, QHeaderView, QTableWidget, QTableWidgetItem, QWidget
4
+ from bec_qthemes import material_icon
5
+ from qtpy.QtCore import Property, Qt, Slot
6
+ from qtpy.QtGui import QColor
7
+ from qtpy.QtWidgets import QHeaderView, QLabel, QTableWidget, QTableWidgetItem, QVBoxLayout, QWidget
6
8
 
9
+ from bec_widgets.qt_utils.toolbar import ModularToolBar, SeparatorAction, WidgetAction
7
10
  from bec_widgets.utils.bec_connector import ConnectionConfig
8
11
  from bec_widgets.utils.bec_widget import BECWidget
12
+ from bec_widgets.widgets.button_abort.button_abort import AbortButton
13
+ from bec_widgets.widgets.button_reset.button_reset import ResetButton
14
+ from bec_widgets.widgets.button_resume.button_resume import ResumeButton
15
+ from bec_widgets.widgets.stop_button.stop_button import StopButton
9
16
 
10
17
 
11
18
  class BECQueue(BECWidget, QWidget):
@@ -14,6 +21,15 @@ class BECQueue(BECWidget, QWidget):
14
21
  """
15
22
 
16
23
  ICON_NAME = "edit_note"
24
+ status_colors = {
25
+ "STOPPED": "red",
26
+ "PENDING": "orange",
27
+ "IDLE": "gray",
28
+ "PAUSED": "yellow",
29
+ "DEFERRED_PAUSE": "lightyellow",
30
+ "RUNNING": "green",
31
+ "COMPLETED": "blue",
32
+ }
17
33
 
18
34
  def __init__(
19
35
  self,
@@ -21,19 +37,79 @@ class BECQueue(BECWidget, QWidget):
21
37
  client=None,
22
38
  config: ConnectionConfig = None,
23
39
  gui_id: str = None,
40
+ refresh_upon_start: bool = True,
24
41
  ):
25
42
  super().__init__(client, config, gui_id)
26
43
  QWidget.__init__(self, parent=parent)
44
+ self.layout = QVBoxLayout(self)
45
+ self.layout.setSpacing(0)
46
+ self.layout.setContentsMargins(0, 0, 0, 0)
47
+
48
+ # Set up the toolbar
49
+ self.set_toolbar()
50
+
51
+ # Set up the table
27
52
  self.table = QTableWidget(self)
28
- self.layout = QHBoxLayout(self)
29
53
  self.layout.addWidget(self.table)
30
-
31
- self.table.setColumnCount(3)
32
- self.table.setHorizontalHeaderLabels(["Scan Number", "Type", "Status"])
54
+ self.table.setColumnCount(4)
55
+ self.table.setHorizontalHeaderLabels(["Scan Number", "Type", "Status", "Cancel"])
33
56
  header = self.table.horizontalHeader()
34
57
  header.setSectionResizeMode(QHeaderView.Stretch)
58
+
35
59
  self.bec_dispatcher.connect_slot(self.update_queue, MessageEndpoints.scan_queue_status())
36
60
  self.reset_content()
61
+ if refresh_upon_start:
62
+ self.refresh_queue()
63
+
64
+ def set_toolbar(self):
65
+ """
66
+ Set the toolbar.
67
+ """
68
+ widget_label = QLabel("Live Queue")
69
+ widget_label.setStyleSheet("font-weight: bold;")
70
+ self.toolbar = ModularToolBar(
71
+ actions={
72
+ "widget_label": WidgetAction(widget=widget_label),
73
+ "separator_1": SeparatorAction(),
74
+ "resume": WidgetAction(widget=ResumeButton(toolbar=False)),
75
+ "stop": WidgetAction(widget=StopButton(toolbar=False)),
76
+ "reset": WidgetAction(widget=ResetButton(toolbar=False)),
77
+ },
78
+ target_widget=self,
79
+ )
80
+
81
+ self.layout.addWidget(self.toolbar)
82
+
83
+ @Property(bool)
84
+ def hide_toolbar(self):
85
+ """Property to hide the BEC Queue toolbar."""
86
+ return not self.toolbar.isVisible()
87
+
88
+ @hide_toolbar.setter
89
+ def hide_toolbar(self, hide: bool):
90
+ """
91
+ Setters for the hide_toolbar property.
92
+
93
+ Args:
94
+ hide(bool): Whether to hide the toolbar.
95
+ """
96
+ self._hide_toolbar(hide)
97
+
98
+ def _hide_toolbar(self, hide: bool):
99
+ """
100
+ Hide the toolbar.
101
+
102
+ Args:
103
+ hide(bool): Whether to hide the toolbar.
104
+ """
105
+ self.toolbar.setVisible(not hide)
106
+
107
+ def refresh_queue(self):
108
+ """
109
+ Refresh the queue.
110
+ """
111
+ msg = self.client.connector.get(MessageEndpoints.scan_queue_status())
112
+ self.update_queue(msg.content, msg.metadata)
37
113
 
38
114
  @Slot(dict, dict)
39
115
  def update_queue(self, content, _metadata):
@@ -57,6 +133,7 @@ class BECQueue(BECWidget, QWidget):
57
133
  blocks = item.get("request_blocks", [])
58
134
  scan_types = []
59
135
  scan_numbers = []
136
+ scan_ids = []
60
137
  status = item.get("status", "")
61
138
  for request_block in blocks:
62
139
  scan_type = request_block.get("content", {}).get("scan_type", "")
@@ -65,13 +142,18 @@ class BECQueue(BECWidget, QWidget):
65
142
  scan_number = request_block.get("scan_number", "")
66
143
  if scan_number:
67
144
  scan_numbers.append(str(scan_number))
145
+ scan_id = request_block.get("scan_id", "")
146
+ if scan_id:
147
+ scan_ids.append(scan_id)
68
148
  if scan_types:
69
149
  scan_types = ", ".join(scan_types)
70
150
  if scan_numbers:
71
151
  scan_numbers = ", ".join(scan_numbers)
72
- self.set_row(index, scan_numbers, scan_types, status)
152
+ if scan_ids:
153
+ scan_ids = ", ".join(scan_ids)
154
+ self.set_row(index, scan_numbers, scan_types, status, scan_ids)
73
155
 
74
- def format_item(self, content: str) -> QTableWidgetItem:
156
+ def format_item(self, content: str, status=False) -> QTableWidgetItem:
75
157
  """
76
158
  Format the content of the table item.
77
159
 
@@ -85,9 +167,17 @@ class BECQueue(BECWidget, QWidget):
85
167
  content = ""
86
168
  item = QTableWidgetItem(content)
87
169
  item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
170
+ # item.setFlags(item.flags() & ~Qt.ItemFlag.ItemIsEditable)
171
+
172
+ if status:
173
+ try:
174
+ color = self.status_colors.get(content, "black") # Default to black if not found
175
+ item.setForeground(QColor(color))
176
+ except:
177
+ return item
88
178
  return item
89
179
 
90
- def set_row(self, index: int, scan_number: str, scan_type: str, status: str):
180
+ def set_row(self, index: int, scan_number: str, scan_type: str, status: str, scan_id: str):
91
181
  """
92
182
  Set the row of the table.
93
183
 
@@ -97,10 +187,42 @@ class BECQueue(BECWidget, QWidget):
97
187
  scan_type (str): The scan type.
98
188
  status (str): The status.
99
189
  """
190
+ abort_button = self._create_abort_button(scan_id)
191
+ abort_button.button.clicked.connect(self.delete_selected_row)
100
192
 
101
193
  self.table.setItem(index, 0, self.format_item(scan_number))
102
194
  self.table.setItem(index, 1, self.format_item(scan_type))
103
- self.table.setItem(index, 2, self.format_item(status))
195
+ self.table.setItem(index, 2, self.format_item(status, status=True))
196
+ self.table.setCellWidget(index, 3, abort_button)
197
+
198
+ def _create_abort_button(self, scan_id: str) -> AbortButton:
199
+ """
200
+ Create an abort button with styling for BEC Queue widget for certain scan_id.
201
+
202
+ Args:
203
+ scan_id(str): The scan id to abort.
204
+
205
+ Returns:
206
+ AbortButton: The abort button.
207
+ """
208
+ abort_button = AbortButton(scan_id=scan_id)
209
+
210
+ abort_button.button.setText("")
211
+ abort_button.button.setIcon(
212
+ material_icon("cancel", color="#cc181e", filled=True, convert_to_pixmap=False)
213
+ )
214
+ abort_button.button.setStyleSheet("background-color: rgba(0,0,0,0) ")
215
+ abort_button.button.setFlat(True)
216
+
217
+ return abort_button
218
+
219
+ def delete_selected_row(self):
220
+
221
+ button = self.sender()
222
+ row = self.table.indexAt(button.pos()).row()
223
+ self.table.removeRow(row)
224
+
225
+ button.deleteLater()
104
226
 
105
227
  def reset_content(self):
106
228
  """
@@ -108,7 +230,7 @@ class BECQueue(BECWidget, QWidget):
108
230
  """
109
231
 
110
232
  self.table.setRowCount(1)
111
- self.set_row(0, "", "", "")
233
+ self.set_row(0, "", "", "", "")
112
234
 
113
235
 
114
236
  if __name__ == "__main__": # pragma: no cover
@@ -11,7 +11,9 @@ class AbortButton(BECWidget, QWidget):
11
11
 
12
12
  ICON_NAME = "cancel"
13
13
 
14
- def __init__(self, parent=None, client=None, config=None, gui_id=None, toolbar=False):
14
+ def __init__(
15
+ self, parent=None, client=None, config=None, gui_id=None, toolbar=False, scan_id=None
16
+ ):
15
17
  super().__init__(client=client, config=config, gui_id=gui_id)
16
18
  QWidget.__init__(self, parent=parent)
17
19
 
@@ -25,17 +27,19 @@ class AbortButton(BECWidget, QWidget):
25
27
  if toolbar:
26
28
  icon = material_icon("cancel", color="#666666", filled=True)
27
29
  self.button = QToolButton(icon=icon)
28
- self.button.triggered.connect(self.abort_scan)
30
+ self.button.setToolTip("Abort the scan")
29
31
  else:
30
32
  self.button = QPushButton()
31
33
  self.button.setText("Abort")
32
34
  self.button.setStyleSheet(
33
35
  "background-color: #666666; color: white; font-weight: bold; font-size: 12px;"
34
36
  )
35
- self.button.clicked.connect(self.abort_scan)
37
+ self.button.clicked.connect(self.abort_scan)
36
38
 
37
39
  self.layout.addWidget(self.button)
38
40
 
41
+ self.scan_id = scan_id
42
+
39
43
  @SafeSlot()
40
44
  def abort_scan(
41
45
  self,
@@ -46,4 +50,8 @@ class AbortButton(BECWidget, QWidget):
46
50
  Args:
47
51
  scan_id(str|None): The scan id to abort. If None, the current scan will be aborted.
48
52
  """
49
- self.queue.request_scan_abortion()
53
+ if self.scan_id is not None:
54
+ print(f"Aborting scan with scan_id: {self.scan_id}")
55
+ self.queue.request_scan_abortion(scan_id=self.scan_id)
56
+ else:
57
+ self.queue.request_scan_abortion()
@@ -1,13 +1,13 @@
1
1
  from bec_qthemes import material_icon
2
2
  from qtpy.QtCore import Qt
3
- from qtpy.QtWidgets import QHBoxLayout, QPushButton, QToolButton, QWidget
3
+ from qtpy.QtWidgets import QHBoxLayout, QMessageBox, QPushButton, QToolButton, QWidget
4
4
 
5
5
  from bec_widgets.qt_utils.error_popups import SafeSlot
6
6
  from bec_widgets.utils.bec_widget import BECWidget
7
7
 
8
8
 
9
9
  class ResetButton(BECWidget, QWidget):
10
- """A button that reset the scan queue."""
10
+ """A button that resets the scan queue."""
11
11
 
12
12
  ICON_NAME = "restart_alt"
13
13
 
@@ -23,20 +23,37 @@ class ResetButton(BECWidget, QWidget):
23
23
  self.layout.setAlignment(Qt.AlignmentFlag.AlignVCenter)
24
24
 
25
25
  if toolbar:
26
- icon = material_icon("restart_alt", color="#F19E39", filled=True)
26
+ icon = material_icon(
27
+ "restart_alt", color="#F19E39", filled=True, convert_to_pixmap=False
28
+ )
27
29
  self.button = QToolButton(icon=icon)
28
- self.button.triggered.connect(self.reset_queue)
30
+ self.button.setToolTip("Reset the scan queue")
29
31
  else:
30
32
  self.button = QPushButton()
31
33
  self.button.setText("Reset Queue")
32
34
  self.button.setStyleSheet(
33
35
  "background-color: #F19E39; color: white; font-weight: bold; font-size: 12px;"
34
36
  )
35
- self.button.clicked.connect(self.reset_queue)
37
+ self.button.clicked.connect(self.confirm_reset_queue)
36
38
 
37
39
  self.layout.addWidget(self.button)
38
40
 
41
+ @SafeSlot()
42
+ def confirm_reset_queue(self):
43
+ """Prompt the user to confirm the queue reset."""
44
+ msg_box = QMessageBox()
45
+ msg_box.setIcon(QMessageBox.Warning)
46
+ msg_box.setWindowTitle("Confirm Reset")
47
+ msg_box.setText(
48
+ "Are you sure you want to reset the scan queue? This action cannot be undone."
49
+ )
50
+ msg_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
51
+ msg_box.setDefaultButton(QMessageBox.No)
52
+
53
+ if msg_box.exec_() == QMessageBox.Yes:
54
+ self.reset_queue()
55
+
39
56
  @SafeSlot()
40
57
  def reset_queue(self):
41
- """Stop the scan."""
58
+ """Reset the scan queue."""
42
59
  self.queue.request_queue_reset()
@@ -23,16 +23,16 @@ class ResumeButton(BECWidget, QWidget):
23
23
  self.layout.setAlignment(Qt.AlignmentFlag.AlignVCenter)
24
24
 
25
25
  if toolbar:
26
- icon = material_icon("resume", color="#2793e8", filled=True)
26
+ icon = material_icon("resume", color="#2793e8", filled=True, convert_to_pixmap=False)
27
27
  self.button = QToolButton(icon=icon)
28
- self.button.triggered.connect(self.continue_scan)
28
+ self.button.setToolTip("Resume the scan queue")
29
29
  else:
30
30
  self.button = QPushButton()
31
31
  self.button.setText("Resume")
32
32
  self.button.setStyleSheet(
33
33
  "background-color: #2793e8; color: white; font-weight: bold; font-size: 12px;"
34
34
  )
35
- self.button.clicked.connect(self.continue_scan)
35
+ self.button.clicked.connect(self.continue_scan)
36
36
 
37
37
  self.layout.addWidget(self.button)
38
38
 
@@ -23,16 +23,16 @@ class StopButton(BECWidget, QWidget):
23
23
  self.layout.setAlignment(Qt.AlignmentFlag.AlignVCenter)
24
24
 
25
25
  if toolbar:
26
- icon = material_icon("stop", color="#cc181e", filled=True)
26
+ icon = material_icon("stop", color="#cc181e", filled=True, convert_to_pixmap=False)
27
27
  self.button = QToolButton(icon=icon)
28
- self.button.triggered.connect(self.stop_scan)
28
+ self.button.setToolTip("Stop the scan queue")
29
29
  else:
30
30
  self.button = QPushButton()
31
31
  self.button.setText("Stop")
32
32
  self.button.setStyleSheet(
33
33
  "background-color: #cc181e; color: white; font-weight: bold; font-size: 12px;"
34
34
  )
35
- self.button.clicked.connect(self.stop_scan)
35
+ self.button.clicked.connect(self.stop_scan)
36
36
 
37
37
  self.layout.addWidget(self.button)
38
38
 
@@ -2,12 +2,27 @@ import os
2
2
  import select
3
3
  import shlex
4
4
  import signal
5
+ import socket
5
6
  import subprocess
6
7
  import sys
7
8
 
8
9
  from bec_widgets.widgets.website.website import WebsiteWidget
9
10
 
10
11
 
12
+ def get_free_port():
13
+ """
14
+ Get a free port on the local machine.
15
+
16
+ Returns:
17
+ int: The free port number
18
+ """
19
+ sock = socket.socket()
20
+ sock.bind(("", 0))
21
+ port = sock.getsockname()[1]
22
+ sock.close()
23
+ return port
24
+
25
+
11
26
  class VSCodeEditor(WebsiteWidget):
12
27
  """
13
28
  A widget to display the VSCode editor.
@@ -15,7 +30,6 @@ class VSCodeEditor(WebsiteWidget):
15
30
 
16
31
  token = "bec"
17
32
  host = "127.0.0.1"
18
- port = 7000
19
33
 
20
34
  USER_ACCESS = []
21
35
  ICON_NAME = "developer_mode_tv"
@@ -23,6 +37,7 @@ class VSCodeEditor(WebsiteWidget):
23
37
  def __init__(self, parent=None, config=None, client=None, gui_id=None):
24
38
 
25
39
  self.process = None
40
+ self.port = get_free_port()
26
41
  self._url = f"http://{self.host}:{self.port}?tkn={self.token}"
27
42
  super().__init__(parent=parent, config=config, client=client, gui_id=gui_id)
28
43
  self.start_server()
@@ -49,6 +64,7 @@ class VSCodeEditor(WebsiteWidget):
49
64
  if output and f"available at {self._url}" in output:
50
65
  break
51
66
  self.set_url(self._url)
67
+ self.wait_until_loaded()
52
68
 
53
69
  def cleanup_vscode(self):
54
70
  """
@@ -1,5 +1,5 @@
1
1
  from qtpy.QtCore import Property, QUrl, Slot, qInstallMessageHandler
2
- from qtpy.QtWebEngineWidgets import QWebEngineView
2
+ from qtpy.QtWebEngineWidgets import QWebEngineSettings, QWebEngineView
3
3
  from qtpy.QtWidgets import QApplication, QVBoxLayout, QWidget
4
4
 
5
5
  from bec_widgets.utils.bec_widget import BECWidget
@@ -32,6 +32,19 @@ class WebsiteWidget(BECWidget, QWidget):
32
32
  self.setLayout(layout)
33
33
  self.set_url(url)
34
34
 
35
+ self._loaded = False
36
+ self.website.loadFinished.connect(self._on_load_finished)
37
+
38
+ def wait_until_loaded(self):
39
+ while not self._loaded:
40
+ QApplication.processEvents()
41
+
42
+ def _on_load_finished(self):
43
+ """
44
+ Callback when the website has finished loading
45
+ """
46
+ self._loaded = True
47
+
35
48
  @Property(str)
36
49
  def url(self) -> str:
37
50
  """
@@ -64,6 +77,7 @@ class WebsiteWidget(BECWidget, QWidget):
64
77
  return
65
78
  if not isinstance(url, str):
66
79
  return
80
+ self._loaded = False
67
81
  self.website.setUrl(QUrl(url))
68
82
 
69
83
  def get_url(self) -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: bec_widgets
3
- Version: 0.101.0
3
+ Version: 0.103.0
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
@@ -1,12 +1,12 @@
1
1
  .gitignore,sha256=cMQ1MLmnoR88aMCCJwUyfoTnufzl4-ckmHtlFUqHcT4,3253
2
- .gitlab-ci.yml,sha256=HE_stq5wl-0wE5ZetfEmaaDbectk20jX7Z2cxwsBegg,8348
2
+ .gitlab-ci.yml,sha256=Dc1iDjsc72UxdUtihx4uSZU0lrTQeR8hZwGx1MQBfKE,8432
3
3
  .pylintrc,sha256=eeY8YwSI74oFfq6IYIbCqnx3Vk8ZncKaatv96n_Y8Rs,18544
4
4
  .readthedocs.yaml,sha256=aSOc277LqXcsTI6lgvm_JY80lMlr69GbPKgivua2cS0,603
5
- CHANGELOG.md,sha256=6RUIXVV1FuM3_7TuNkxIHYQddeGb56Fx1mIlcTI29ss,6594
5
+ CHANGELOG.md,sha256=abbFjREleIlw-KWxjTt2ZeXKTuUoXVZohRHwZKCEbdQ,6861
6
6
  LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
7
- PKG-INFO,sha256=Mikp7NvbMPYwdD8rtGYW_lMVdY0B8HmOsnlVF-fy5mA,1334
7
+ PKG-INFO,sha256=ryZgSj3emn4stYet02hDdz1wPwtYB1d_2vmJ_E25unU,1334
8
8
  README.md,sha256=Od69x-RS85Hph0-WwWACwal4yUd67XkEn4APEfHhHFw,2649
9
- pyproject.toml,sha256=D8jXP_3VO8qU5fKbBIS7LRgam7O3evOJvLkkPvanF3A,2544
9
+ pyproject.toml,sha256=AZloCb8F4BsMTj5wlWFeonigrmle-L0zd96zTyOZfRc,2544
10
10
  .git_hooks/pre-commit,sha256=n3RofIZHJl8zfJJIUomcMyYGFi_rwq4CC19z0snz3FI,286
11
11
  .gitlab/issue_templates/bug_report_template.md,sha256=gAuyEwl7XlnebBrkiJ9AqffSNOywmr8vygUFWKTuQeI,386
12
12
  .gitlab/issue_templates/documentation_update_template.md,sha256=FHLdb3TS_D9aL4CYZCjyXSulbaW5mrN2CmwTaeLPbNw,860
@@ -46,13 +46,13 @@ bec_widgets/qt_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
46
46
  bec_widgets/qt_utils/error_popups.py,sha256=y9gKKWaafp468ioHr96nBhf02ZpEgjDc-BAVOTWh-e8,7680
47
47
  bec_widgets/qt_utils/redis_message_waiter.py,sha256=fvL_QgC0cTDv_FPJdRyp5AKjf401EJU4z3r38p47ydY,1745
48
48
  bec_widgets/qt_utils/settings_dialog.py,sha256=NhtzTer_xzlB2lLLrGklkI1QYLJEWQpJoZbCz4o5daI,3645
49
- bec_widgets/qt_utils/toolbar.py,sha256=oP1Lxos03MuwSTonPeILknHEXfZlKsuK13jrXoI2pck,8530
49
+ bec_widgets/qt_utils/toolbar.py,sha256=QMXTbEFowVzbQzblXZVJcAhgd_zrqaqBISyd4QlPv1A,8576
50
50
  bec_widgets/utils/__init__.py,sha256=1930ji1Jj6dVuY81Wd2kYBhHYNV-2R0bN_L4o9zBj1U,533
51
51
  bec_widgets/utils/bec_connector.py,sha256=SivHKXVyNVqeu3kCXYEPpbleTVw8g1cW0FKq1QrQgco,9987
52
52
  bec_widgets/utils/bec_designer.py,sha256=Z3MeMju-KmTz8POtm23VQfp4rvtD2sF6eIOKQkl2F7w,4729
53
53
  bec_widgets/utils/bec_dispatcher.py,sha256=NkObWO_gRO9Uobz-fy0gVTZqQsbFRaKj6fbjYZoErFI,6400
54
54
  bec_widgets/utils/bec_table.py,sha256=nA2b8ukSeUfquFMAxGrUVOqdrzMoDYD6O_4EYbOG2zk,717
55
- bec_widgets/utils/bec_widget.py,sha256=ANFx-Ll5mjOjmILniTH5jKBITDijUtfFLb1eoiXoFws,2881
55
+ bec_widgets/utils/bec_widget.py,sha256=cQIAXdQJQWTtWPshOdMT-UMxfrah7BM8n059YGofyX0,3158
56
56
  bec_widgets/utils/colors.py,sha256=N3GbVBpExfC1m_dnYFDoua-iRLM90E5kTKVOIkZVmDM,12372
57
57
  bec_widgets/utils/container_utils.py,sha256=0wr3ZfuMiAFKCrQHVjxjw-Vuk8wsHdridqcjy2eY840,1531
58
58
  bec_widgets/utils/crosshair.py,sha256=8lik9k69WI2WMj5FGLbrKtny9duxqXUJAhpX8tHoyp0,11543
@@ -73,7 +73,7 @@ bec_widgets/widgets/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKV
73
73
  bec_widgets/widgets/base_classes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
74
  bec_widgets/widgets/base_classes/device_input_base.py,sha256=thCOHOa9Z0b3-vlNFWK6PT_DdPTANnfj0_DLES_K-eE,3902
75
75
  bec_widgets/widgets/bec_queue/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
76
- bec_widgets/widgets/bec_queue/bec_queue.py,sha256=izsCw9yFjPtmcQFGhUBSylRI6egFFwF7Nd7SGog_zu8,3911
76
+ bec_widgets/widgets/bec_queue/bec_queue.py,sha256=8gayhWyIB3_gdpeongGTDQxHs37Waf3H5TDjySCctho,7998
77
77
  bec_widgets/widgets/bec_queue/bec_queue.pyproject,sha256=VhoNmAv1DQUl9dg7dELyf5i4pZ5k65N3GnqOYiSwbQo,27
78
78
  bec_widgets/widgets/bec_queue/bec_queue_plugin.py,sha256=cotVUNKphAXQAp6mWtKoyzJ-vyAnfd86tGf4yNp0CjU,1341
79
79
  bec_widgets/widgets/bec_queue/register_bec_queue.py,sha256=XnwtUSa1asK1b80knKWodcyX9qJy4DnKsQL_FoDfZy4,463
@@ -86,15 +86,15 @@ bec_widgets/widgets/bec_status_box/status_item.py,sha256=3aNaa-e64PmkBoAWfItYAmh
86
86
  bec_widgets/widgets/button_abort/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
87
87
  bec_widgets/widgets/button_abort/abort_button.pyproject,sha256=UtuaE0Lvs6uOGufhatUyJS_n2l6EBbYaGuILj_BNCLs,30
88
88
  bec_widgets/widgets/button_abort/abort_button_plugin.py,sha256=3q0a4UE2O9s96Jjg6wi03CpXdQ7CnOI20ep7etEdxMo,1285
89
- bec_widgets/widgets/button_abort/button_abort.py,sha256=TpmxyG3GP-4RWTDJ9gSLyoD8aOYGJRzLC65fpxNSJTE,1688
89
+ bec_widgets/widgets/button_abort/button_abort.py,sha256=-ehjYladvYcfdER7jAQkJ06yT3S4A_Nj9isgEuTspLM,1925
90
90
  bec_widgets/widgets/button_abort/register_abort_button.py,sha256=IthCqJIaCR25ELRqMssSzve_7CE8G54wDlBVY0gPSNI,475
91
91
  bec_widgets/widgets/button_reset/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
92
- bec_widgets/widgets/button_reset/button_reset.py,sha256=AnWC6i1j7yVudmX6FKGOZBNd5KKmhvl7DzDKYKxLwxg,1470
92
+ bec_widgets/widgets/button_reset/button_reset.py,sha256=OL3zRBryBgdMJ_0WSbCNI69BhBIk7vhocsZt2XSM1QM,2107
93
93
  bec_widgets/widgets/button_reset/register_reset_button.py,sha256=IuCaPrqKqF9acVBL2k1St0exsb3rwQF_Y1-QciDEVjw,475
94
94
  bec_widgets/widgets/button_reset/reset_button.pyproject,sha256=JC7XLsjgYzTAh6BV3KmxtT3w4ZUH91wiqIeGefnCjMk,30
95
95
  bec_widgets/widgets/button_reset/reset_button_plugin.py,sha256=QW4ToNqnwh55hN6GMAId1C65vkPYRTAoPTWcXRFvWLw,1291
96
96
  bec_widgets/widgets/button_resume/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
97
- bec_widgets/widgets/button_resume/button_resume.py,sha256=MH6JqiA2GkModbS0EC0_k5cYHIVVkuY9P3hylYLYfE0,1467
97
+ bec_widgets/widgets/button_resume/button_resume.py,sha256=-LAiRTu_ntp1s1wz52MWSodwgJLGUFUR9WnHwz5uIJQ,1486
98
98
  bec_widgets/widgets/button_resume/register_resume_button.py,sha256=01t5Ruz7FkKt7vHUVHvRNgEKqRLbKDza3ZQxd4w0i8A,479
99
99
  bec_widgets/widgets/button_resume/resume_button.pyproject,sha256=QEPSupXQtXZDfT1Y0PuCv7Fj6NhBTq1dyvRiFNkvhH8,31
100
100
  bec_widgets/widgets/button_resume/resume_button_plugin.py,sha256=sqGn2I5XlsEpCjqZQBX8KNYpONJVAkBbzfFZL8OAsxI,1300
@@ -210,7 +210,7 @@ bec_widgets/widgets/spinner/spinner_widget.pyproject,sha256=zzLajGB3DTgVnrSqMey2
210
210
  bec_widgets/widgets/spinner/spinner_widget_plugin.py,sha256=AZYJJe40olMzqL6Edk6J-X_iNHcXrU-EQN4mCUCp_Fo,1355
211
211
  bec_widgets/widgets/stop_button/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
212
212
  bec_widgets/widgets/stop_button/register_stop_button.py,sha256=U7r3fEOH-uPhAQI-nTituHXDDXDWR4JQZ7_vD6b_dfM,471
213
- bec_widgets/widgets/stop_button/stop_button.py,sha256=TiCXLisaTdHKCcsNl5yMBUsYH9zUfwbeEe3zJrGH8qQ,1686
213
+ bec_widgets/widgets/stop_button/stop_button.py,sha256=ODcyoBZChJZnLn2jDO94ECLHnpf3Y5DkmiAl3SUopms,1707
214
214
  bec_widgets/widgets/stop_button/stop_button.pyproject,sha256=Cc_xbv-zfzNVpsdg_1QyzuTlrJaM9_BkIjes70umrx0,29
215
215
  bec_widgets/widgets/stop_button/stop_button_plugin.py,sha256=VT-WVLq89fw7PwML7JDMCF1bqfopLCZIgMA4yetl65M,1365
216
216
  bec_widgets/widgets/text_box/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -227,7 +227,7 @@ bec_widgets/widgets/vscode/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
227
227
  bec_widgets/widgets/vscode/register_vs_code_editor.py,sha256=JATKBkTEuReeQ2Jj402xasjgVRMFI8uUOAAwmnFOWRA,473
228
228
  bec_widgets/widgets/vscode/vs_code_editor.pyproject,sha256=bxx0jZlSfBo-Em7p15W1QIJ9lFr9jqTqGynUQG01ocU,24
229
229
  bec_widgets/widgets/vscode/vs_code_editor_plugin.py,sha256=exFR6HTVdLLPfn2U6BMDugPoxZaebcHTnHWMrX2n_d4,1338
230
- bec_widgets/widgets/vscode/vscode.py,sha256=KReXQ5y-Bs-F1Tc0-_1f6c0dC5_MlgkWPGhUgbOORO0,2267
230
+ bec_widgets/widgets/vscode/vscode.py,sha256=3HDWYJZPi4lNr7gW4IabTYyivMdhZGhq5ETGlJihqlc,2579
231
231
  bec_widgets/widgets/waveform/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
232
232
  bec_widgets/widgets/waveform/bec_waveform_widget.pyproject,sha256=GLD8GN9dXx9wNbtnevrxqqcwk7vKV-Uv8QYSycdaoaI,33
233
233
  bec_widgets/widgets/waveform/bec_waveform_widget_plugin.py,sha256=qSQTeCzIUn8rgDkjIM47Rr3-fqg1uk8rDf_lCoY9gZw,1402
@@ -241,11 +241,11 @@ bec_widgets/widgets/waveform/waveform_popups/dap_summary_dialog/__init__.py,sha2
241
241
  bec_widgets/widgets/waveform/waveform_popups/dap_summary_dialog/dap_summary_dialog.py,sha256=XOHppMcONwfhAYpqIc51VOrpunWmPSn50sT3I0MjW2c,1173
242
242
  bec_widgets/widgets/website/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
243
243
  bec_widgets/widgets/website/register_website_widget.py,sha256=LIQJpV9uqcBiPR9cEAiDjaUS_l7JroYVdsotnLpD9H0,476
244
- bec_widgets/widgets/website/website.py,sha256=kDlqjwtx0yft1ZNRhTdHnYh_5KZHfqT_ZGPOKT4C-yI,2619
244
+ bec_widgets/widgets/website/website.py,sha256=42pncCc_zI2eqeMArIurVmPUukRo5bTxa2h1Skah-io,3012
245
245
  bec_widgets/widgets/website/website_widget.pyproject,sha256=scOiV3cV1_BjbzpPzy2N8rIJL5P2qIZz8ObTJ-Uvdtg,25
246
246
  bec_widgets/widgets/website/website_widget_plugin.py,sha256=pz38_C2cZ0yvPPS02wdIPcmhFo_yiwUhflsASocAPQQ,1341
247
- bec_widgets-0.101.0.dist-info/METADATA,sha256=Mikp7NvbMPYwdD8rtGYW_lMVdY0B8HmOsnlVF-fy5mA,1334
248
- bec_widgets-0.101.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
249
- bec_widgets-0.101.0.dist-info/entry_points.txt,sha256=3otEkCdDB9LZJuBLzG4pFLK5Di0CVybN_12IsZrQ-58,166
250
- bec_widgets-0.101.0.dist-info/licenses/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
251
- bec_widgets-0.101.0.dist-info/RECORD,,
247
+ bec_widgets-0.103.0.dist-info/METADATA,sha256=ryZgSj3emn4stYet02hDdz1wPwtYB1d_2vmJ_E25unU,1334
248
+ bec_widgets-0.103.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
249
+ bec_widgets-0.103.0.dist-info/entry_points.txt,sha256=3otEkCdDB9LZJuBLzG4pFLK5Di0CVybN_12IsZrQ-58,166
250
+ bec_widgets-0.103.0.dist-info/licenses/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
251
+ bec_widgets-0.103.0.dist-info/RECORD,,
pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "bec_widgets"
7
- version = "0.101.0"
7
+ version = "0.103.0"
8
8
  description = "BEC Widgets"
9
9
  requires-python = ">=3.10"
10
10
  classifiers = [