mirror of
https://github.com/bec-project/bec_widgets.git
synced 2026-03-05 00:12:49 +01:00
fix: clean up, run cli script, add docs
This commit is contained in:
@@ -19,7 +19,6 @@ class Widgets(str, enum.Enum):
|
||||
BECColorMapWidget = "BECColorMapWidget"
|
||||
BECDockArea = "BECDockArea"
|
||||
BECImageWidget = "BECImageWidget"
|
||||
BECMainWindow = "BECMainWindow"
|
||||
BECMotorMapWidget = "BECMotorMapWidget"
|
||||
BECMultiWaveformWidget = "BECMultiWaveformWidget"
|
||||
BECProgressBar = "BECProgressBar"
|
||||
@@ -43,6 +42,7 @@ class Widgets(str, enum.Enum):
|
||||
SignalLineEdit = "SignalLineEdit"
|
||||
StopButton = "StopButton"
|
||||
TextBox = "TextBox"
|
||||
UserScriptWidget = "UserScriptWidget"
|
||||
VSCodeEditor = "VSCodeEditor"
|
||||
WebsiteWidget = "WebsiteWidget"
|
||||
|
||||
@@ -64,6 +64,13 @@ class AbortButton(RPCBase):
|
||||
Get all registered RPC objects.
|
||||
"""
|
||||
|
||||
@property
|
||||
@rpc_call
|
||||
def _rpc_id(self) -> "str":
|
||||
"""
|
||||
Get the RPC ID of the widget.
|
||||
"""
|
||||
|
||||
|
||||
class BECColorMapWidget(RPCBase):
|
||||
@property
|
||||
@@ -3682,6 +3689,9 @@ class TextBox(RPCBase):
|
||||
"""
|
||||
|
||||
|
||||
class UserScriptWidget(RPCBase): ...
|
||||
|
||||
|
||||
class VSCodeEditor(RPCBase): ...
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
def main(): # pragma: no cover
|
||||
from qtpy import PYSIDE6
|
||||
|
||||
if not PYSIDE6:
|
||||
print("PYSIDE6 is not available in the environment. Cannot patch designer.")
|
||||
return
|
||||
from PySide6.QtDesigner import QPyDesignerCustomWidgetCollection
|
||||
|
||||
from bec_widgets.widgets.editors.user_script.user_script_widget_plugin import (
|
||||
UserScriptWidgetPlugin,
|
||||
)
|
||||
|
||||
QPyDesignerCustomWidgetCollection.addCustomWidget(UserScriptWidgetPlugin())
|
||||
|
||||
|
||||
if __name__ == "__main__": # pragma: no cover
|
||||
main()
|
||||
@@ -0,0 +1 @@
|
||||
{'files': ['user_script.py']}
|
||||
@@ -0,0 +1,54 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
from qtpy.QtDesigner import QDesignerCustomWidgetInterface
|
||||
|
||||
from bec_widgets.utils.bec_designer import designer_material_icon
|
||||
from bec_widgets.widgets.editors.user_script.user_script import UserScriptWidget
|
||||
|
||||
DOM_XML = """
|
||||
<ui language='c++'>
|
||||
<widget class='UserScriptWidget' name='user_script_widget'>
|
||||
</widget>
|
||||
</ui>
|
||||
"""
|
||||
|
||||
|
||||
class UserScriptWidgetPlugin(QDesignerCustomWidgetInterface): # pragma: no cover
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._form_editor = None
|
||||
|
||||
def createWidget(self, parent):
|
||||
t = UserScriptWidget(parent)
|
||||
return t
|
||||
|
||||
def domXml(self):
|
||||
return DOM_XML
|
||||
|
||||
def group(self):
|
||||
return "BEC Services"
|
||||
|
||||
def icon(self):
|
||||
return designer_material_icon(UserScriptWidget.ICON_NAME)
|
||||
|
||||
def includeFile(self):
|
||||
return "user_script_widget"
|
||||
|
||||
def initialize(self, form_editor):
|
||||
self._form_editor = form_editor
|
||||
|
||||
def isContainer(self):
|
||||
return False
|
||||
|
||||
def isInitialized(self):
|
||||
return self._form_editor is not None
|
||||
|
||||
def name(self):
|
||||
return "UserScriptWidget"
|
||||
|
||||
def toolTip(self):
|
||||
return "Dialog for displaying the fit summary and params for LMFit DAP processes"
|
||||
|
||||
def whatsThis(self):
|
||||
return self.toolTip()
|
||||
BIN
docs/assets/widget_screenshots/user_script_widget.png
Normal file
BIN
docs/assets/widget_screenshots/user_script_widget.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
35
docs/user/widgets/user_script_widget/user_script_widget.md
Normal file
35
docs/user/widgets/user_script_widget/user_script_widget.md
Normal file
@@ -0,0 +1,35 @@
|
||||
(user.widgets.user_script_widget)=
|
||||
# User Script Widget
|
||||
|
||||
````{tab} Overview
|
||||
|
||||
The [`UserScriptWidget`] is designed to allow users to run their user-defined scripts directly from a BEC GUI. This widget lists all available user scripts and allows users to execute them with a single click. The widget also provides an interface to open a VSCode editor to modify the files hosting the user scripts. This widget is particularly useful to provide a user-friendly interface to run custom scripts to users without using the command line. We note that the scripts are executed in a BEC client that does not share the full namespace with the BEC IPython kernel.
|
||||
|
||||
## Key Features:
|
||||
- **User Script Execution**: Run user-defined scripts directly from the BEC GUI.
|
||||
- **VSCode Integration**: Open the VSCode editor to modify the files hosting the user scripts.
|
||||
|
||||
|
||||
````{tab} Examples
|
||||
|
||||
The `UserScriptWidget` widget can be integrated within a [`BECDockArea`](user.widgets.bec_dock_area) or used as an individual component in your application through `BECDesigner`. Below are examples demonstrating how to create and use the `BECStatusBox` widget.
|
||||
|
||||
## Example 1 - Adding BEC Status Box to BECDockArea
|
||||
|
||||
In this example, we demonstrate how to add a `BECStatusBox` widget to a `BECDockArea`, allowing users to monitor the status of BEC processes directly from the GUI.
|
||||
|
||||
```python
|
||||
# Add a new dock with a BECStatusBox widget
|
||||
user_script = gui.add_dock().add_widget("UserScriptWidget")
|
||||
```
|
||||
|
||||
```{hint}
|
||||
The widget will automatically display the list of available user scripts. Users can click on the script name to execute it.
|
||||
```
|
||||
````
|
||||
|
||||
````{tab} API
|
||||
```{eval-rst}
|
||||
.. include:: /api_reference/_autosummary/bec_widgets.cli.client.UserScriptWidget.rst
|
||||
```
|
||||
````
|
||||
@@ -134,6 +134,15 @@ Display status of BEC services.
|
||||
|
||||
Display current scan queue.
|
||||
```
|
||||
|
||||
```{grid-item-card} User Script Widget
|
||||
:link: user.widgets.user_script_widget
|
||||
:link-type: ref
|
||||
:img-top: /assets/widget_screenshots/user_script_widget.png
|
||||
|
||||
Run user-defined scripts directly from the BEC GUI.
|
||||
```
|
||||
|
||||
````
|
||||
|
||||
## BEC Utility Widgets
|
||||
@@ -238,6 +247,7 @@ Display DAP summaries of LMFit models in a window.
|
||||
|
||||
Select DAP model from a list of DAP processes.
|
||||
```
|
||||
|
||||
````
|
||||
|
||||
```{toctree}
|
||||
@@ -270,5 +280,6 @@ signal_input/signal_input.md
|
||||
position_indicator/position_indicator.md
|
||||
lmfit_dialog/lmfit_dialog.md
|
||||
dap_combo_box/dap_combo_box.md
|
||||
user_script_widget/user_script_widget.md
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user