def addDockWidget(self, area, dock): pass # not a plugin API method """Add dock widget to previous position, if known. Otherwise add to specified area """ assert not dock in self._addedDockWidgets self._addedDockWidgets.append(dock) if self.restoreDockWidget(dock): return else: QMainWindow.addDockWidget(self, area, dock)
def test_dock_mainwinow(self): mw = QMainWindow() dock = CollapsibleDockWidget() w1 = QTextEdit() w2 = QToolButton() w2.setFixedSize(38, 200) dock.setExpandedWidget(w1) dock.setCollapsedWidget(w2) mw.addDockWidget(Qt.LeftDockWidgetArea, dock) mw.setCentralWidget(QTextEdit()) mw.show() def toogle(): dock.setExpanded(not dock.expanded()) self.singleShot(2000, toogle) toogle() self.app.exec_()
def collapsed(self): return self.mainWidget.isCollapsed() collapsed = property(collapsed, setCollapsed) def toggleCollapsed(self): self.setCollapsed(self.collapsed) self.stateChanged.emit(self.collapsed) if __name__ == "__main__": import sys from PyQt4.QtGui import QApplication, QMainWindow, QComboBox, QPushButton, QTextEdit app = QApplication(sys.argv) win = QMainWindow() dock1 = XDockWidget("1st dockwidget", win) dock1.setFeatures(QDockWidget.DockWidgetFloatable | QDockWidget.DockWidgetMovable) combo = QComboBox(dock1) dock1.setWidget(combo) win.addDockWidget(Qt.LeftDockWidgetArea, dock1) dock2 = XDockWidget("2nd dockwidget") button = QPushButton("Hello, world!", dock2) dock2.setWidget(button) win.addDockWidget(Qt.RightDockWidgetArea, dock2) edit = QTextEdit(win) win.setCentralWidget(edit) win.resize(640, 480) win.show() app.exec_()
slice_settings = SliceSettingsWidget(max_slice_count=nz, color_scales=color_scales.keys()) slice_settings.inactiveCellsHidden.connect(viewer.hideInactiveCells) slice_settings.currentSliceChanged.connect(viewer.setCurrentSlice) slice_settings.toggleOrthographicProjection.connect(viewer.useOrthographicProjection) slice_settings.toggleLighting.connect(viewer.useLighting) slice_settings.colorScalesChanged.connect(viewer.changeColorScale) slice_settings.regionToggling.connect(viewer.useRegionScaling) slice_settings.toggleInterpolation.connect(viewer.useInterpolationOnData) slice_settings.mirrorX.connect(viewer.mirrorX) slice_settings.mirrorY.connect(viewer.mirrorY) slice_settings.mirrorZ.connect(viewer.mirrorZ) slice_settings.toggleFlatPolylines.connect(viewer.toggleFlatPolylines) dock_widget = QDockWidget("Settings") dock_widget.setObjectName("SliceSettingsDock") dock_widget.setWidget(slice_settings) dock_widget.setAllowedAreas(Qt.AllDockWidgetAreas) dock_widget.setFeatures(QDockWidget.NoDockWidgetFeatures) window.addDockWidget(Qt.LeftDockWidgetArea, dock_widget) window.setCentralWidget(viewer) window.show() window.activateWindow() window.raise_() app.exec_()
def isCollapsed(self): return self.mainWidget.isCollapsed() def toggleCollapsed(self): self.setCollapsed(not self.isCollapsed()) if __name__ == "__main__": import sys from PyQt4.QtGui import QTextEdit app = QApplication(sys.argv) app.setStyle("qtcurve") win = QMainWindow() dock1 = DockWidget("1st dockwidget", win) dock1.setFeatures(dock1.features() | QDockWidget.DockWidgetVerticalTitleBar) combo = QComboBox(dock1) dock1.setWidget(combo) win.addDockWidget(Qt.LeftDockWidgetArea, dock1) dock2 = DockWidget("2nd dockwidget") dock2.setFeatures(dock1.features() | QDockWidget.DockWidgetVerticalTitleBar) button = QPushButton("Hello, world!", dock2) dock2.setWidget(button) win.addDockWidget(Qt.RightDockWidgetArea, dock2) edit = QTextEdit(win) win.setCentralWidget(edit) win.resize(640, 480) win.show() app.exec_()
def addDockWidget(self, area, dockwidget): dockwidget.dockLocationChanged.connect(self.updateTabConnections) return QMainWindow.addDockWidget(self, area, dockwidget)
slice_settings.inactiveCellsHidden.connect(viewer.hideInactiveCells) slice_settings.currentSliceChanged.connect(viewer.setCurrentSlice) slice_settings.toggleOrthographicProjection.connect(viewer.useOrthographicProjection) slice_settings.toggleLighting.connect(viewer.useLighting) slice_settings.colorScalesChanged.connect(viewer.changeColorScale) slice_settings.regionToggling.connect(viewer.useRegionScaling) slice_settings.toggleInterpolation.connect(viewer.useInterpolationOnData) slice_settings.mirrorX.connect(viewer.mirrorX) slice_settings.mirrorY.connect(viewer.mirrorY) slice_settings.mirrorZ.connect(viewer.mirrorZ) slice_settings.toggleFlatPolylines.connect(viewer.toggleFlatPolylines) dock_widget = QDockWidget("Settings") dock_widget.setObjectName("SliceSettingsDock") dock_widget.setWidget(slice_settings) dock_widget.setAllowedAreas(Qt.AllDockWidgetAreas) dock_widget.setFeatures(QDockWidget.NoDockWidgetFeatures) window.addDockWidget(Qt.LeftDockWidgetArea, dock_widget) window.setCentralWidget(viewer) window.show() window.activateWindow() window.raise_() app.exec_()