mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-13 19:21:50 +02:00
feat(launcher): add option for launching with auto updates
This commit is contained in:
@ -1,6 +1,23 @@
|
||||
from bec_widgets.cli.auto_updates import AutoUpdates
|
||||
from bec_widgets.widgets.containers.dock.dock_area import BECDockArea
|
||||
|
||||
|
||||
def dock_area(object_name: str | None = None):
|
||||
_dock_area = BECDockArea(object_name=object_name)
|
||||
return _dock_area
|
||||
|
||||
|
||||
def auto_update_dock_area(object_name: str | None = None) -> BECDockArea:
|
||||
"""
|
||||
Create a dock area with auto update enabled.
|
||||
|
||||
Args:
|
||||
object_name(str): The name of the dock area.
|
||||
|
||||
Returns:
|
||||
BECDockArea: The created dock area.
|
||||
"""
|
||||
_dock_area = BECDockArea(object_name=object_name)
|
||||
_dock_area.set_auto_update(AutoUpdates)
|
||||
_dock_area.auto_update.enabled = True # type:ignore
|
||||
return _dock_area
|
||||
|
@ -22,7 +22,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<widget class="QPushButton" name="open_auto_update_dock_area">
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
|
@ -1,23 +1,23 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from bec_lib.logger import bec_logger
|
||||
from qtpy.QtCore import QSize
|
||||
from qtpy.QtGui import QAction, QActionGroup
|
||||
from qtpy.QtWidgets import QApplication, QMainWindow, QSizePolicy, QStyle
|
||||
from qtpy.QtWidgets import QApplication, QSizePolicy
|
||||
|
||||
import bec_widgets
|
||||
from bec_widgets.cli.rpc.rpc_register import RPCRegister
|
||||
from bec_widgets.utils import UILoader
|
||||
from bec_widgets.utils.bec_widget import BECWidget
|
||||
from bec_widgets.utils.colors import apply_theme
|
||||
from bec_widgets.utils.container_utils import WidgetContainerUtils
|
||||
from bec_widgets.widgets.containers.dock.dock_area import BECDockArea
|
||||
from bec_widgets.widgets.containers.main_window.addons.web_links import BECWebLinksMixin
|
||||
from bec_widgets.widgets.containers.main_window.main_window import BECMainWindow
|
||||
|
||||
logger = bec_logger.logger
|
||||
MODULE_PATH = os.path.dirname(bec_widgets.__file__)
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
from qtpy.QtWidgets import QWidget
|
||||
|
||||
|
||||
class LaunchWindow(BECMainWindow):
|
||||
RPC = True
|
||||
@ -36,20 +36,27 @@ class LaunchWindow(BECMainWindow):
|
||||
self.load_ui(ui_file_path)
|
||||
self.ui.open_dock_area.setText("Open Dock Area")
|
||||
self.ui.open_dock_area.clicked.connect(lambda: self.launch("dock_area"))
|
||||
self.ui.open_auto_update_dock_area.setText("Open Dock Area with Auto Update")
|
||||
self.ui.open_auto_update_dock_area.clicked.connect(
|
||||
lambda: self.launch("auto_update_dock_area", "auto_updates")
|
||||
)
|
||||
|
||||
def launch(
|
||||
self,
|
||||
launch_script: str,
|
||||
name: str | None = None,
|
||||
geometry: tuple[int, int, int, int] | None = None,
|
||||
) -> "BECDockArea":
|
||||
"""Create a new dock area.
|
||||
) -> QWidget:
|
||||
"""Launch the specified script. If the launch script creates a QWidget, it will be
|
||||
embedded in a BECMainWindow. If the launch script creates a BECMainWindow, it will be shown
|
||||
as a separate window.
|
||||
|
||||
Args:
|
||||
launch_script(str): The name of the script to be launched.
|
||||
name(str): The name of the dock area.
|
||||
geometry(tuple): The geometry parameters to be passed to the dock area.
|
||||
Returns:
|
||||
BECDockArea: The newly created dock area.
|
||||
QWidget: The created dock area.
|
||||
"""
|
||||
from bec_widgets.applications import bw_launch
|
||||
|
||||
|
Reference in New Issue
Block a user