def create(self): layout = qt.QVBoxLayout(self) # buttons frame self.structureButtonsFrame = qt.QFrame() self.structureButtonsFrame.objectName = 'ButtonsFrame' self.structureButtonsFrame.setLayout(qt.QHBoxLayout()) layout.addWidget(self.structureButtonsFrame) # add button self.addStructureButton = qt.QPushButton("Add Structure") self.addStructureButton.objectName = 'AddStructureButton' self.addStructureButton.setToolTip( "Add a label volume for a structure to edit") self.structureButtonsFrame.layout().addWidget(self.addStructureButton) # split button self.splitButton = qt.QPushButton("Split Merge Volume") self.splitButton.objectName = 'SplitStructureButton' self.splitButton.setToolTip( "Split distinct labels from merge volume into new volumes") self.structureButtonsFrame.layout().addWidget(self.splitButton) # structures view self.structuresView = qt.QTreeView() self.structuresView.objectName = 'StructuresView' self.structuresView.sortingEnabled = True layout.addWidget(self.structuresView) # all buttons frame self.allButtonsFrame = qt.QFrame() self.allButtonsFrame.objectName = 'AllButtonsFrameButton' self.allButtonsFrame.setLayout(qt.QHBoxLayout()) layout.addWidget(self.allButtonsFrame) # delete all structures button self.deleteStructuresButton = qt.QPushButton("Delete All") self.deleteStructuresButton.objectName = 'DeleteStructureButton' self.deleteStructuresButton.setToolTip( "Delete all the structure volumes from the scene.\n\nNote: to delete individual structure volumes, use the Data Module." ) self.allButtonsFrame.layout().addWidget(self.deleteStructuresButton) # delete selected structures button self.deleteSelectedStructureButton = qt.QPushButton("Delete Selected") self.deleteSelectedStructureButton.objectName = 'DeleteSelectedStructureButton' self.deleteSelectedStructureButton.setToolTip( "Delete the selected structure volume from the scene.") self.allButtonsFrame.layout().addWidget( self.deleteSelectedStructureButton) # merge button self.mergeButton = qt.QPushButton("Merge All") self.mergeButton.objectName = 'MergeAllStructuresButton' self.mergeButton.setToolTip("Merge all structures into Merge Volume") self.allButtonsFrame.layout().addWidget(self.mergeButton) # merge and build button self.mergeAndBuildButton = qt.QPushButton("Merge And Build") self.mergeAndBuildButton.objectName = 'MergeStructuresAndBuildModelsButton' self.mergeAndBuildButton.setToolTip( "Merge all structures into Merge Volume and build models from all structures" ) self.allButtonsFrame.layout().addWidget(self.mergeAndBuildButton) # options frame self.optionsFrame = qt.QFrame() self.optionsFrame.objectName = 'OptionsFrame' self.optionsFrame.setLayout(qt.QHBoxLayout()) layout.addWidget(self.optionsFrame) # replace models button self.replaceModels = qt.QCheckBox("Replace Models") self.replaceModels.objectName = 'ReplaceModelsCheckBox' self.replaceModels.setToolTip( "Replace any existing models when building") self.replaceModels.setChecked(1) self.optionsFrame.layout().addWidget(self.replaceModels)
def setup(self): # Instantiate and connect widgets ... icon = self.parent.style().standardIcon(qt.QStyle.SP_ArrowForward) iconSize = qt.QSize(22, 22) def createToolButton(text): tb = qt.QToolButton() tb.text = text tb.icon = icon font = tb.font font.setBold(True) font.setPixelSize(14) tb.font = font tb.iconSize = iconSize tb.toolButtonStyle = qt.Qt.ToolButtonTextBesideIcon tb.autoRaise = True return tb def createReadOnlyLineEdit(): le = qt.QLineEdit() le.readOnly = True le.frame = False le.styleSheet = "QLineEdit { background:transparent; }" le.cursor = qt.QCursor(qt.Qt.IBeamCursor) return le # # Tools Area # self.toolsCollapsibleButton = ctk.ctkCollapsibleButton() self.toolsCollapsibleButton.text = "Extension Tools" self.layout.addWidget(self.toolsCollapsibleButton) self.createExtensionButton = createToolButton("Create Extension") self.createExtensionButton.connect('clicked(bool)', self.createExtension) self.selectExtensionButton = createToolButton("Select Extension") self.selectExtensionButton.connect('clicked(bool)', self.selectExtension) toolsLayout = qt.QVBoxLayout(self.toolsCollapsibleButton) toolsLayout.addWidget(self.createExtensionButton) toolsLayout.addWidget(self.selectExtensionButton) # # Editor Area # self.editorCollapsibleButton = ctk.ctkCollapsibleButton() self.editorCollapsibleButton.text = "Extension Editor" self.editorCollapsibleButton.enabled = False self.editorCollapsibleButton.collapsed = True self.layout.addWidget(self.editorCollapsibleButton) self.extensionNameField = createReadOnlyLineEdit() self.extensionLocationField = createReadOnlyLineEdit() self.extensionRepositoryField = createReadOnlyLineEdit() self.extensionContentsModel = qt.QFileSystemModel() self.extensionContentsView = qt.QTreeView() self.extensionContentsView.setModel(self.extensionContentsModel) self.extensionContentsView.sortingEnabled = True self.extensionContentsView.hideColumn(3) self.createExtensionModuleButton = createToolButton( "Add Module to Extension") self.createExtensionModuleButton.connect('clicked(bool)', self.createExtensionModule) self.editExtensionMetadataButton = createToolButton( "Edit Extension Metadata") self.editExtensionMetadataButton.connect('clicked(bool)', self.editExtensionMetadata) editorLayout = qt.QFormLayout(self.editorCollapsibleButton) editorLayout.addRow("Name:", self.extensionNameField) editorLayout.addRow("Location:", self.extensionLocationField) editorLayout.addRow("Repository:", self.extensionRepositoryField) editorLayout.addRow("Contents:", self.extensionContentsView) editorLayout.addRow(self.createExtensionModuleButton) editorLayout.addRow(self.editExtensionMetadataButton) # Add vertical spacer self.layout.addStretch(1)