def save_layout(self): """ Get the dictionary representation of the dock layout. """ areas = [] widget = self.dock_area.layoutWidget() if widget is not None: areas.append(dockarea(save_layout(widget))) for handler in self.handlers: if handler.floating: container = handler.dock_container area = dockarea(save_layout(container), floating=True) geo = container.geometry() area.geometry = (geo.x(), geo.y(), geo.width(), geo.height()) areas.append(area) return docklayout(*areas)
def save_layout(self): """ Get the current layout of the dock area. Returns ------- result : docklayout A docklayout instance which represents the current layout state. """ primary = None secondary = [] area = self._dock_area widget = area.layoutWidget() if widget is not None: primary = dockarea(save_layout(widget)) maxed = area.maximizedWidget() if maxed is not None: primary.maximized_item = maxed.objectName() for frame in self._floating_frames(): if isinstance(frame, QDockWindow): area = frame.dockArea() item = dockarea(save_layout(area.layoutWidget())) maxed = area.maximizedWidget() if maxed is not None: item.maximized_item = maxed.objectName() else: item = save_layout(frame) item.linked = frame.isLinked() item.maximized = frame.isMaximized() if frame.isMaximized(): geo = frame.normalGeometry() else: geo = frame.geometry() item.geometry = (geo.x(), geo.y(), geo.width(), geo.height()) secondary.append(item) return docklayout(primary, *secondary)
def coerce_layout(thing): """ Coerce a variety of objects into a docklayout. Parameters ---------- thing : dict, basetring, dockitem, dockarea, split, or tabs Something that can be coerced into a dock layout. """ if isinstance(thing, basestring): thing = dockitem(thing) if isinstance(thing, (dockitem, docksplit, docktabs)): return docklayout(dockarea(thing)) if isinstance(thing, dockarea): return docklayout(thing) msg = "cannot coerce '%s' to a docklayout" raise TypeError(msg % type(thing).__name__)
def coerce_layout(thing): """ Coerce a variety of objects into a docklayout. Parameters ---------- thing : dict, basetring, dockitem, dockarea, split, or tabs Something that can be coerced into a dock layout. """ if thing is None: return docklayout(None) if isinstance(thing, basestring): thing = dockitem(thing) if isinstance(thing, (dockitem, docksplit, docktabs)): return docklayout(dockarea(thing)) if isinstance(thing, dockarea): return docklayout(thing) msg = "cannot coerce '%s' to a 'docklayout'" raise TypeError(msg % type(thing).__name__)