mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-13 19:21:50 +02:00
fix(dock): new dock can be detached upon creation
This commit is contained in:
@ -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,
|
||||
|
@ -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:
|
||||
|
Reference in New Issue
Block a user