bec-widgets 0.117.0__py3-none-any.whl → 0.117.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.
CHANGELOG.md CHANGED
@@ -1,6 +1,19 @@
1
1
  # CHANGELOG
2
2
 
3
3
 
4
+ ## v0.117.1 (2024-10-11)
5
+
6
+ ### Fixes
7
+
8
+ * fix(FPS): qtimer cleanup leaking ([`3a22392`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/3a2239278075de7489ad10a58c31d7d89715e221))
9
+
10
+ ### Unknown
11
+
12
+ * feature(vscode): added support for vscode instructions ([`f5f1f6c`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/f5f1f6c304b890dc162e8653005233bce4ea82e4))
13
+
14
+ * feature(vscode): support for controlling vscode from widgets ([`9238679`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/923867947f62db026ac0378c30ef62c883596058))
15
+
16
+
4
17
  ## v0.117.0 (2024-10-11)
5
18
 
6
19
  ### Features
@@ -159,18 +172,3 @@ Fixes #361, do not try to change x axis when not permitted ([`efa2763`](https://
159
172
  ### Features
160
173
 
161
174
  * feat(accent colors): added helper function to get all accent colors ([`84a59f7`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/84a59f70eed6d8a3c3aeeabc77a5f9ea4e864f61))
162
-
163
- ### Fixes
164
-
165
- * fix(theme): fixed theme access for themecontainer ([`de303f0`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/de303f0227fc9d3a74a0410f1e7999ac5132273c))
166
-
167
-
168
- ## v0.108.0 (2024-09-06)
169
-
170
- ### Documentation
171
-
172
- * docs(progressbar): added docs ([`7d07cea`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/7d07cea946f9c884477b01bebfb60b332ff09e0a))
173
-
174
- ### Features
175
-
176
- * feat(progressbar): added bec progressbar ([`f6d1d0b`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/f6d1d0bbe3ba30a3b7291cd36a1f7f8e6bd5b895))
PKG-INFO CHANGED
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: bec_widgets
3
- Version: 0.117.0
3
+ Version: 0.117.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
@@ -452,13 +452,14 @@ class BECPlotBase(BECConnector, pg.GraphicsLayout):
452
452
 
453
453
  self.fps_monitor.sigFpsUpdate.connect(self.update_fps_label)
454
454
 
455
- def unhook_fps_monitor(self):
455
+ def unhook_fps_monitor(self, delete_label=True):
456
456
  """Unhook the FPS monitor from the plot."""
457
457
  if self.fps_monitor is not None:
458
458
  # Remove Monitor
459
459
  self.fps_monitor.cleanup()
460
460
  self.fps_monitor.deleteLater()
461
461
  self.fps_monitor = None
462
+ if self.fps_label is not None and delete_label:
462
463
  # Remove Label
463
464
  self.removeItem(self.fps_label)
464
465
  self.fps_label.deleteLater()
@@ -490,6 +491,7 @@ class BECPlotBase(BECConnector, pg.GraphicsLayout):
490
491
  def cleanup_pyqtgraph(self):
491
492
  """Cleanup pyqtgraph items."""
492
493
  self.unhook_crosshair()
494
+ self.unhook_fps_monitor(delete_label=False)
493
495
  self.tick_item.cleanup()
494
496
  self.arrow_item.cleanup()
495
497
  item = self.plot_item
@@ -5,10 +5,19 @@ import signal
5
5
  import socket
6
6
  import subprocess
7
7
  import sys
8
+ from typing import Literal
9
+
10
+ from pydantic import BaseModel
11
+ from qtpy.QtCore import Signal, Slot
8
12
 
9
13
  from bec_widgets.widgets.website.website import WebsiteWidget
10
14
 
11
15
 
16
+ class VSCodeInstructionMessage(BaseModel):
17
+ command: Literal["open", "write", "close", "zenMode", "save", "new", "setCursor"]
18
+ content: str = ""
19
+
20
+
12
21
  def get_free_port():
13
22
  """
14
23
  Get a free port on the local machine.
@@ -28,6 +37,8 @@ class VSCodeEditor(WebsiteWidget):
28
37
  A widget to display the VSCode editor.
29
38
  """
30
39
 
40
+ file_saved = Signal(str)
41
+
31
42
  token = "bec"
32
43
  host = "127.0.0.1"
33
44
 
@@ -41,6 +52,7 @@ class VSCodeEditor(WebsiteWidget):
41
52
  self._url = f"http://{self.host}:{self.port}?tkn={self.token}"
42
53
  super().__init__(parent=parent, config=config, client=client, gui_id=gui_id)
43
54
  self.start_server()
55
+ self.bec_dispatcher.connect_slot(self.on_vscode_event, f"vscode-events/{self.gui_id}")
44
56
 
45
57
  def start_server(self):
46
58
  """
@@ -49,11 +61,19 @@ class VSCodeEditor(WebsiteWidget):
49
61
  This method starts the server for the VSCode editor in a subprocess.
50
62
  """
51
63
 
64
+ env = os.environ.copy()
65
+ env["BEC_Widgets_GUIID"] = self.gui_id
66
+ env["BEC_REDIS_HOST"] = self.client.connector.host
52
67
  cmd = shlex.split(
53
68
  f"code serve-web --port {self.port} --connection-token={self.token} --accept-server-license-terms"
54
69
  )
55
70
  self.process = subprocess.Popen(
56
- cmd, text=True, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, preexec_fn=os.setsid
71
+ cmd,
72
+ text=True,
73
+ stdout=subprocess.PIPE,
74
+ stderr=subprocess.DEVNULL,
75
+ preexec_fn=os.setsid,
76
+ env=env,
57
77
  )
58
78
 
59
79
  os.set_blocking(self.process.stdout.fileno(), False)
@@ -66,6 +86,92 @@ class VSCodeEditor(WebsiteWidget):
66
86
  self.set_url(self._url)
67
87
  self.wait_until_loaded()
68
88
 
89
+ @Slot(str)
90
+ def open_file(self, file_path: str):
91
+ """
92
+ Open a file in the VSCode editor.
93
+
94
+ Args:
95
+ file_path: The file path to open
96
+ """
97
+ msg = VSCodeInstructionMessage(command="open", content=f"file://{file_path}")
98
+ self.client.connector.raw_send(f"vscode-instructions/{self.gui_id}", msg.model_dump_json())
99
+
100
+ @Slot(dict, dict)
101
+ def on_vscode_event(self, content, _metadata):
102
+ """
103
+ Handle the VSCode event. VSCode events are received as RawMessages.
104
+
105
+ Args:
106
+ content: The content of the event
107
+ metadata: The metadata of the event
108
+ """
109
+
110
+ # the message also contains the content but I think is fine for now to just emit the file path
111
+ if not isinstance(content["data"], dict):
112
+ return
113
+ if "uri" not in content["data"]:
114
+ return
115
+ if not content["data"]["uri"].startswith("file://"):
116
+ return
117
+ file_path = content["data"]["uri"].split("file://")[1]
118
+ self.file_saved.emit(file_path)
119
+
120
+ @Slot()
121
+ def save_file(self):
122
+ """
123
+ Save the file in the VSCode editor.
124
+ """
125
+ msg = VSCodeInstructionMessage(command="save")
126
+ self.client.connector.raw_send(f"vscode-instructions/{self.gui_id}", msg.model_dump_json())
127
+
128
+ @Slot()
129
+ def new_file(self):
130
+ """
131
+ Create a new file in the VSCode editor.
132
+ """
133
+ msg = VSCodeInstructionMessage(command="new")
134
+ self.client.connector.raw_send(f"vscode-instructions/{self.gui_id}", msg.model_dump_json())
135
+
136
+ @Slot()
137
+ def close_file(self):
138
+ """
139
+ Close the file in the VSCode editor.
140
+ """
141
+ msg = VSCodeInstructionMessage(command="close")
142
+ self.client.connector.raw_send(f"vscode-instructions/{self.gui_id}", msg.model_dump_json())
143
+
144
+ @Slot(str)
145
+ def write_file(self, content: str):
146
+ """
147
+ Write content to the file in the VSCode editor.
148
+
149
+ Args:
150
+ content: The content to write
151
+ """
152
+ msg = VSCodeInstructionMessage(command="write", content=content)
153
+ self.client.connector.raw_send(f"vscode-instructions/{self.gui_id}", msg.model_dump_json())
154
+
155
+ @Slot()
156
+ def zen_mode(self):
157
+ """
158
+ Toggle the Zen mode in the VSCode editor.
159
+ """
160
+ msg = VSCodeInstructionMessage(command="zenMode")
161
+ self.client.connector.raw_send(f"vscode-instructions/{self.gui_id}", msg.model_dump_json())
162
+
163
+ @Slot(int, int)
164
+ def set_cursor(self, line: int, column: int):
165
+ """
166
+ Set the cursor in the VSCode editor.
167
+
168
+ Args:
169
+ line: The line number
170
+ column: The column number
171
+ """
172
+ msg = VSCodeInstructionMessage(command="setCursor", content=f"{line},{column}")
173
+ self.client.connector.raw_send(f"vscode-instructions/{self.gui_id}", msg.model_dump_json())
174
+
69
175
  def cleanup_vscode(self):
70
176
  """
71
177
  Cleanup the VSCode editor.
@@ -79,6 +185,7 @@ class VSCodeEditor(WebsiteWidget):
79
185
  """
80
186
  Cleanup the widget. This method is called from the dock area when the widget is removed.
81
187
  """
188
+ self.bec_dispatcher.disconnect_slot(self.on_vscode_event, f"vscode-events/{self.gui_id}")
82
189
  self.cleanup_vscode()
83
190
  return super().cleanup()
84
191
 
@@ -89,7 +196,7 @@ if __name__ == "__main__": # pragma: no cover
89
196
  from qtpy.QtWidgets import QApplication
90
197
 
91
198
  app = QApplication(sys.argv)
92
- widget = VSCodeEditor()
199
+ widget = VSCodeEditor(gui_id="unknown")
93
200
  widget.show()
94
201
  app.exec_()
95
202
  widget.bec_dispatcher.disconnect_all()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: bec_widgets
3
- Version: 0.117.0
3
+ Version: 0.117.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
@@ -2,11 +2,11 @@
2
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=P2FvQRmkrzZeRyx-2Okb6dqpPawiUEEua4eQjG0ffNI,7492
5
+ CHANGELOG.md,sha256=l7OerEQLFUkgRP8ee9m3Pt33SvtAgXGysgXk7rrYG2o,7500
6
6
  LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
7
- PKG-INFO,sha256=qzAx_QzNjl7iO4_f8Bz9YYq3XG9n3Lv2VGGKUY5X48M,1334
7
+ PKG-INFO,sha256=b_z8MIDR_146jZCXbjcxnzt8q1jbf2NZ1QRfjcUFBk4,1334
8
8
  README.md,sha256=Od69x-RS85Hph0-WwWACwal4yUd67XkEn4APEfHhHFw,2649
9
- pyproject.toml,sha256=kyGOtgZp4UfDCXDm7NnGWUox2z3FHW5lri9ZUU-g3Yg,2594
9
+ pyproject.toml,sha256=z_RxPwnuA9ck8UUX9jWpMRdyO-3DugNJkJoAtGYh1mk,2594
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
@@ -164,7 +164,7 @@ bec_widgets/widgets/figure/figure.py,sha256=IzQaV_9utjViJyjMydOa3-EJ9k-FVG2PTVm8
164
164
  bec_widgets/widgets/figure/plots/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
165
165
  bec_widgets/widgets/figure/plots/axis_settings.py,sha256=grgrX4t4eAzccW4jj4HYtMSxy8Wgcd9N9J1aU7UHtIs,3723
166
166
  bec_widgets/widgets/figure/plots/axis_settings.ui,sha256=ye-guaRU_jhu7sHZS-9AjBjLrCtA1msOD0dszu4o9x8,11785
167
- bec_widgets/widgets/figure/plots/plot_base.py,sha256=FIPvigIHenScR3T1NitRdlY_CXJmuAjCY8fv3GQzrRM,18053
167
+ bec_widgets/widgets/figure/plots/plot_base.py,sha256=7c1HQaGwxsN2vQOFuF5Z68Gp-hbeHOI04C4wvWQs89w,18180
168
168
  bec_widgets/widgets/figure/plots/image/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
169
169
  bec_widgets/widgets/figure/plots/image/image.py,sha256=FmvVVKLtMOAvaRL1tF30KLO0yQVCZqxCqydQIesKgdc,25044
170
170
  bec_widgets/widgets/figure/plots/image/image_item.py,sha256=TwHo6FwCiQgJBdr-KKy_7Y_vYSB0pPjBl1AubuZSrE0,11002
@@ -248,7 +248,7 @@ bec_widgets/widgets/vscode/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
248
248
  bec_widgets/widgets/vscode/register_vs_code_editor.py,sha256=JATKBkTEuReeQ2Jj402xasjgVRMFI8uUOAAwmnFOWRA,473
249
249
  bec_widgets/widgets/vscode/vs_code_editor.pyproject,sha256=bxx0jZlSfBo-Em7p15W1QIJ9lFr9jqTqGynUQG01ocU,24
250
250
  bec_widgets/widgets/vscode/vs_code_editor_plugin.py,sha256=exFR6HTVdLLPfn2U6BMDugPoxZaebcHTnHWMrX2n_d4,1338
251
- bec_widgets/widgets/vscode/vscode.py,sha256=3HDWYJZPi4lNr7gW4IabTYyivMdhZGhq5ETGlJihqlc,2579
251
+ bec_widgets/widgets/vscode/vscode.py,sha256=c4Uef-xp5gJqVJdw82nWJWF-iTWz4Zsx4HhgbsGhe-E,6181
252
252
  bec_widgets/widgets/waveform/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
253
253
  bec_widgets/widgets/waveform/bec_waveform_widget.pyproject,sha256=GLD8GN9dXx9wNbtnevrxqqcwk7vKV-Uv8QYSycdaoaI,33
254
254
  bec_widgets/widgets/waveform/bec_waveform_widget_plugin.py,sha256=qSQTeCzIUn8rgDkjIM47Rr3-fqg1uk8rDf_lCoY9gZw,1402
@@ -265,8 +265,8 @@ bec_widgets/widgets/website/register_website_widget.py,sha256=LIQJpV9uqcBiPR9cEA
265
265
  bec_widgets/widgets/website/website.py,sha256=42pncCc_zI2eqeMArIurVmPUukRo5bTxa2h1Skah-io,3012
266
266
  bec_widgets/widgets/website/website_widget.pyproject,sha256=scOiV3cV1_BjbzpPzy2N8rIJL5P2qIZz8ObTJ-Uvdtg,25
267
267
  bec_widgets/widgets/website/website_widget_plugin.py,sha256=pz38_C2cZ0yvPPS02wdIPcmhFo_yiwUhflsASocAPQQ,1341
268
- bec_widgets-0.117.0.dist-info/METADATA,sha256=qzAx_QzNjl7iO4_f8Bz9YYq3XG9n3Lv2VGGKUY5X48M,1334
269
- bec_widgets-0.117.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
270
- bec_widgets-0.117.0.dist-info/entry_points.txt,sha256=dItMzmwA1wizJ1Itx15qnfJ0ZzKVYFLVJ1voxT7K7D4,214
271
- bec_widgets-0.117.0.dist-info/licenses/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
272
- bec_widgets-0.117.0.dist-info/RECORD,,
268
+ bec_widgets-0.117.1.dist-info/METADATA,sha256=b_z8MIDR_146jZCXbjcxnzt8q1jbf2NZ1QRfjcUFBk4,1334
269
+ bec_widgets-0.117.1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
270
+ bec_widgets-0.117.1.dist-info/entry_points.txt,sha256=dItMzmwA1wizJ1Itx15qnfJ0ZzKVYFLVJ1voxT7K7D4,214
271
+ bec_widgets-0.117.1.dist-info/licenses/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
272
+ bec_widgets-0.117.1.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.117.0"
7
+ version = "0.117.1"
8
8
  description = "BEC Widgets"
9
9
  requires-python = ">=3.10"
10
10
  classifiers = [