From 02a26086c4540127a11c235cba30afc4fd712007 Mon Sep 17 00:00:00 2001 From: wyzula-jan Date: Fri, 7 Jun 2024 10:59:47 +0200 Subject: [PATCH] fix(dock): new dock can be detached upon creation --- bec_widgets/widgets/dock/dock.py | 32 --------------------------- bec_widgets/widgets/dock/dock_area.py | 4 ++++ 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/bec_widgets/widgets/dock/dock.py b/bec_widgets/widgets/dock/dock.py index 56329145..198af61d 100644 --- a/bec_widgets/widgets/dock/dock.py +++ b/bec_widgets/widgets/dock/dock.py @@ -153,38 +153,6 @@ class BECDock(BECConnector, Dock): """ return list(RPCWidgetHandler.widget_classes.keys()) - # def add_widget_bec( - # self, - # widget_type: str, - # row=None, - # col=0, - # rowspan=1, - # colspan=1, - # shift: Literal["down", "up", "left", "right"] = "down", - # ): - # """ - # Add a widget to the dock. - # - # Args: - # widget_type(str): The widget to add. Only BEC RPC widgets from RPCWidgetHandler are allowed. - # row(int): The row to add the widget to. If None, the widget will be added to the next available row. - # col(int): The column to add the widget to. - # rowspan(int): The number of rows the widget should span. - # colspan(int): The number of columns the widget should span. - # shift(Literal["down", "up", "left", "right"]): The direction to shift the widgets if the position is occupied. - # """ - # if row is None: - # row = self.layout.rowCount() - # - # if self.layout_manager.is_position_occupied(row, col): - # self.layout_manager.shift_widgets(shift, start_row=row) - # - # widget = RPCWidgetHandler.create_widget(widget_type) - # self.addWidget(widget, row=row, col=col, rowspan=rowspan, colspan=colspan) - # self.config.widgets[widget.gui_id] = widget.config - # - # return widget - def add_widget( self, widget: BECConnector | str, diff --git a/bec_widgets/widgets/dock/dock_area.py b/bec_widgets/widgets/dock/dock_area.py index 2f4b3a11..8bec8366 100644 --- a/bec_widgets/widgets/dock/dock_area.py +++ b/bec_widgets/widgets/dock/dock_area.py @@ -137,6 +137,7 @@ class BECDockArea(BECConnector, DockArea): position: Literal["bottom", "top", "left", "right", "above", "below"] = None, relative_to: BECDock | None = None, closable: bool = False, + floating: bool = False, prefix: str = "dock", widget: str | QWidget | None = None, row: int = None, @@ -152,6 +153,7 @@ class BECDockArea(BECConnector, DockArea): position(Literal["bottom", "top", "left", "right", "above", "below"]): The position of the dock. relative_to(BECDock): The dock to which the new dock should be added relative to. closable(bool): Whether the dock is closable. + floating(bool): Whether the dock is detached after creating. prefix(str): The prefix for the dock name if no name is provided. widget(str|QWidget|None): The widget to be added to the dock. While using RPC, only BEC RPC widgets from RPCWidgetHandler are allowed. row(int): The row of the added widget. @@ -192,6 +194,8 @@ class BECDockArea(BECConnector, DockArea): if self._instructions_visible: self._instructions_visible = False self.update() + if floating: + dock.detach() return dock def detach_dock(self, dock_name: str) -> BECDock: