def makeButtons(_Settings_Hosts): """ As described. @param _Settings_Hosts: The widget that is the parent of the modal. @param _Settings_Hosts: Settings_Hosts """ addButton = XnatSlicerUtils.generateButton(iconOrLabel='Add', toolTip="Need tool-tip.", font=Settings_Hosts.FONT, size=qt.QSize(90, 20), enabled=True) editButton = XnatSlicerUtils.generateButton(iconOrLabel='Edit', toolTip="Need tool-tip.", font=Settings_Hosts.FONT, size=qt.QSize(90, 20), enabled=True) deleteButton = XnatSlicerUtils.generateButton(iconOrLabel='Delete', toolTip="Need tool-tip.", font=Settings_Hosts.FONT, size=qt.QSize(90, 20), enabled=True) deleteButton.setEnabled(False) editButton.setEnabled(False) return addButton, editButton, deleteButton
def __init__(self, parent): super(CaseReportsWindow, self).__init__() self.mainLayout = qt.QVBoxLayout(self) self.setLayout(self.mainLayout) self.resize(400, 300) self.label = qt.QLabel("Data stored in the module: ") self.label.setStyleSheet("margin: 10px 0 15px 0") self.mainLayout.addWidget(self.label) self.tableView = qt.QTableView() self.tableView.setColumnWidth(0,125) self.tableView.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding) self.mainLayout.addWidget(self.tableView) self.exportButton = ctk.ctkPushButton() self.exportButton.text = "Export" self.exportButton.setFixedWidth(150) self.exportButton.setIcon(qt.QIcon("{0}/export-csv.png".format(SlicerUtil.CIP_ICON_DIR))) self.exportButton.setIconSize(qt.QSize(24,24)) self.mainLayout.addWidget(self.exportButton) self.removeButton = ctk.ctkPushButton() self.removeButton.text = "Clean cache" self.removeButton.setIcon(qt.QIcon("{0}/delete.png".format(SlicerUtil.CIP_ICON_DIR))) self.removeButton.setIconSize(qt.QSize(24,24)) self.removeButton.setFixedWidth(150) self.mainLayout.addWidget(self.removeButton) self.exportButton.connect('clicked()', parent.onExport) self.removeButton.connect('clicked()', parent.onRemoveStoredData)
def setup(self): self.saveValuesButton = ctk.ctkPushButton() self.saveValuesButton.text = "Save" self.saveValuesButton.setIcon(qt.QIcon("{0}/Save.png".format(SlicerUtil.CIP_ICON_DIR))) self.saveValuesButton.setIconSize(qt.QSize(24,24)) self.layout.addWidget(self.saveValuesButton) self.openButton = ctk.ctkPushButton() self.openButton.text = "Open" self.openButton.setIcon(qt.QIcon("{0}/open_file.png".format(SlicerUtil.CIP_ICON_DIR))) self.openButton.setIconSize(qt.QSize(24,24)) self.layout.addWidget(self.openButton) self.exportButton = ctk.ctkPushButton() self.exportButton.text = "Export" self.exportButton.setIcon(qt.QIcon("{0}/export-csv.png".format(SlicerUtil.CIP_ICON_DIR))) self.exportButton.setIconSize(qt.QSize(24,24)) self.layout.addWidget(self.exportButton) self.removeButton = ctk.ctkPushButton() self.removeButton.setIcon(qt.QIcon("{0}/delete.png".format(SlicerUtil.CIP_ICON_DIR))) self.removeButton.setIconSize(qt.QSize(24,24)) self.removeButton.text = "Clean cache" self.layout.addWidget(self.removeButton) self.saveValuesButton.connect('clicked()', self.onSave) self.exportButton.connect('clicked()', self.onExport) self.openButton.connect('clicked()', self.onShowStoredData) self.removeButton.connect('clicked()', self.onRemoveStoredData)
class XnatSlicerGlobals(object): """ XnatSlicerGlobals contains static properites relevant to the XnatSlicer module. """ LIB_URI = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ROOT_URI = os.path.dirname(LIB_URI) CACHE_URI = os.path.join(ROOT_URI, 'Cache') RESOURCES_URI = os.path.join(ROOT_URI, 'Resources') LOCAL_URIS = { "home": ROOT_URI, "settings": os.path.join(ROOT_URI, "Settings"), "projects": os.path.join(CACHE_URI, "projects"), "downloads": os.path.join(CACHE_URI, "downloads"), "uploads": os.path.join(CACHE_URI, "uploads"), "icons": os.path.join(RESOURCES_URI, "Icons"), } DICOM_EXTENSIONS = [".dcm", ".ima", ".dicom"] ANALYZE_EXTENSIONS = [".hdr", ".img"] MISC_LOADABLE_EXTENSIONS = [ ".nii", ".nrrd", ".img", ".nhdr", ".dc", ".raw.gz", ".gz", ".vtk", ".stl", ".acsv" ] DECOMPRESSIBLE_EXTENSIONS = [".gz", ".zip", ".tar"] MRML_EXTENSIONS = [".mrml"] ALL_LOADABLE_EXTENSIONS = DICOM_EXTENSIONS + ANALYZE_EXTENSIONS + \ MISC_LOADABLE_EXTENSIONS BUTTON_SIZE_MED = qt.QSize(45, 45) BUTTON_SIZE_SMALL = qt.QSize(28, 28) FONT_NAME = "Arial" FONT_SIZE = 10 LABEL_FONT = qt.QFont(FONT_NAME, FONT_SIZE, 10, False) LABEL_FONT_LARGE = qt.QFont(FONT_NAME, FONT_SIZE + 2, 10, False) LABEL_FONT_BOLD = qt.QFont(FONT_NAME, FONT_SIZE, 100, False) LABEL_FONT_ITALIC = qt.QFont(FONT_NAME, FONT_SIZE, 10, True) LABEL_FONT_ITALIC_LARGE = qt.QFont(FONT_NAME, FONT_SIZE + 2, 10, True) CUSTOM_METADATA_SETTINGS_PREFIX = 'customMetadataTags_' SLICER_FOLDER_NAME = "Slicer" REQUIRED_SLICER_FOLDERS = [SLICER_FOLDER_NAME] DEFAULT_XNAT_SAVE_LEVEL = "experiments" DEFAULT_SLICER_EXTENSION = ".mrb" SLICER_PACKAGE_EXTENSIONS = [".zip", ".mrb"] DEFAULT_SCENE_NAME = "SlicerScene_"
def setup(self): """This is called one time when the module GUI is initialized """ ScriptedLoadableModuleWidget.setup(self) # Create objects that can be used anywhere in the module. Example: in most cases there should be just one # object of the logic class self.logic = CIP_BlankLogic() # Create all the widgets. Main Area mainAreaCollapsibleButton = ctk.ctkCollapsibleButton() mainAreaCollapsibleButton.text = "Main parameters" self.layout.addWidget(mainAreaCollapsibleButton) # Layout within the dummy collapsible button. See http://doc.qt.io/qt-4.8/layout.html for more info about layouts self.mainAreaLayout = qt.QFormLayout(mainAreaCollapsibleButton) # Example button with some common properties self.exampleButton = ctk.ctkPushButton() self.exampleButton.text = "Push me!" self.exampleButton.toolTip = "This is the button tooltip" self.exampleButton.setIcon( qt.QIcon("{0}/Reload.png".format(SlicerUtil.CIP_ICON_DIR))) self.exampleButton.setIconSize(qt.QSize(20, 20)) self.exampleButton.setStyleSheet("font-weight:bold; font-size:12px") self.exampleButton.setFixedWidth(200) self.mainAreaLayout.addWidget(self.exampleButton) # Connections self.exampleButton.connect('clicked()', self.onApplyButton)
def setup(self): ScriptedLoadableModuleWidget.setup(self) self.timeout = 3000 self.extensionFileDialog = None self.moduleFileDialog = None 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 # Instantiate and connect widgets ... # # Parameters Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Developer tools for extensions" self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # Select extension to install self.extensionSelector = createToolButton("Install extension archive") self.extensionSelector.setToolTip("Select extension archive that\ has been locally created or manually downloaded" ) parametersFormLayout.addRow(self.extensionSelector) # Select script module to load self.moduleSelector = createToolButton("Load module") self.moduleSelector.setToolTip( "Select a module you want to load in Slicer") parametersFormLayout.addRow(self.moduleSelector) # connections self.extensionSelector.connect('clicked(bool)', self.onExtensionSelect) self.moduleSelector.connect('clicked(bool)', self.onModuleSelect) # Add vertical spacer self.layout.addStretch(1) # Create logic self.logic = DeveloperToolsForExtensionsLogic()
def test_DICOMwebInterface1(self): """ Ideally you should have several levels of tests. At the lowest level tests should exercise the functionality of the logic with different inputs (both valid and invalid). At higher levels your tests should emulate the way the user would interact with your code and confirm that it still works the way you intended. One of the most important features of the tests is that it should alert other developers when their changes will have an impact on the behavior of your module. For example, if a developer removes a feature that you depend on, your test should break so they know that the feature is needed. """ self.delayDisplay("Starting the test", 50) webPath = os.path.dirname( os.path.dirname(slicer.modules.dicomwebinterface.path)) url = 'file://' + os.path.join(webPath, 'StudyBrowser/index.html') webWidget = slicer.qSlicerWebWidget() slicerGeometry = slicer.util.mainWindow().geometry webWidget.size = qt.QSize(900, 600) webWidget.pos = qt.QPoint(slicerGeometry.x() + 256, slicerGeometry.y() + 128) self.dicomWebServer = 'https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs' webWidget.url = url + "?server=" + self.dicomWebServer print(url) webWidget.show() slicer.modules.DICOMwebInterfaceWidget.webWidget = webWidget
def onAnimationFinished(self): """ Callback function when the animation finishes. Also calls the user-inputted 'onExpand' callback or 'onCollapse' callbacks depending on the toggle state of the widget. """ #---------------- # Call the animate function one last time. #---------------- self.onAnimateMain( qt.QSize(self.geometry.width(), self.geometry.height())) #---------------- # If the widget is in a 'toggled' state. #---------------- if self.toggled: # # Set its height to either 'stretchHeight' # or 'maxHeight. For an explanation of 'stretchHeight' # see it's declaration in the __init__ function. # if self.stretchHeight: self.setMaximumHeight(self.stretchHeight) else: self.setMaximumHeight(self.maxHeight) self.setMinimumHeight(self.minHeight) # # Show the internal contents # self.showContentsWidgets() # # Run the the 'onExpand' callback. # if self.onExpand: self.onExpand() #---------------- # Otherwise if it is 'collapsed' #---------------- else: # # Set the height to 'self.collapsedHeight'. # self.setFixedHeight(self.collapsedHeight) # # Run callbacks # if self.onCollapse: self.onCollapse()
def addSortAndFilterButtons(self): """ Adds the sort/filter buttons to the settings widgets and connects their click events accordingly. """ #-------------------- # Create buttons #-------------------- self.buttons = {} self.buttons['sort'] = {} self.buttons['sort'] = { 'accessed': self.MODULE.utils.generateButton( iconOrLabel='Last Accessed', toolTip= "Sort projects, prioritizing those accessed by current user.", font=self.MODULE.GLOBALS.LABEL_FONT, size=qt.QSize(90, 20), enabled=True) } self.buttons['sort']['accessed'].setCheckable(True) self.buttons['sort']['accessed'].setChecked(False) #-------------------- # Callback for when the filter # button is clicked. #-------------------- def accessedToggled(toggled): if toggled: self.MODULE.XnatView.filter_accessed() else: self.MODULE.XnatView.filter_all() #-------------------- # Connect the filter button to # the button click. #-------------------- self.buttons['sort']['accessed'].connect('toggled(bool)', accessedToggled) #-------------------- # Make the button layout #-------------------- self.sortButtonLayout = qt.QHBoxLayout() for key, value in self.buttons['sort'].iteritems(): self.sortButtonLayout.addWidget(value) self.sortButtonLayout.addStretch() #-------------------- # Create a "Filter Projects By" section. #-------------------- self.addSection("Filter Projects By:", self.sortButtonLayout)
def addItemsByType(self, textList, itemType=None): """ Adds an item to the list widget according to the specificed arguments: the text and the itemType. The itemType argument is optional: if it's not set then the default QListWidgetItem flags are applied. See http://harmattan-dev.nokia.com/docs/library/html/qt4/qt.html#ItemDataRole-enum for further descriptions of the item types. TODO: Add support for more item types beyond the checkbox. """ #-------------------- # Call parent function 'addItems' #-------------------- self.addItems(textList) #-------------------- # If 'itemType' is specified, set the # items accordingly # # TODO: Add more support for the various # item types. #-------------------- if itemType: for i in range(0, self.count): # # CHECKBOXES # if itemType == 'checkbox': # # Set the checkbox size. # checkboxSize = qt.QSize(20, 20) self.item(i).setSizeHint(checkboxSize) # # Flags for checkboxes. # self.item(i).setFlags(4 | 8 | 16 | 32) self.item(i).setCheckState(0) # # DISABLED # elif itemType == 'disabled': self.item(i).setFlags(0)
def setupUi( self ): self.loadUi('InitialStep.ui') moduleName = 'Workflow' scriptedModulesPath = eval('slicer.modules.%s.path' % moduleName.lower()) scriptedModulesPath = os.path.dirname(scriptedModulesPath) iconsPath = os.path.join(scriptedModulesPath, 'Widgets', 'Resources', 'Icons') buttonGroup = qt.QButtonGroup(self.get('InitialCollapsibleGroupBox')) logic = slicer.modules.workflow.logic() resourceDir = qt.QDir(logic.GetModuleShareDirectory() + '/Resources') for dir in resourceDir.entryList(resourceDir.Dirs | resourceDir.NoDotAndDotDot): pushButton = qt.QPushButton(self.get('InitialCollapsibleGroupBox')) buttonGroup.addButton(pushButton) pushButton.text = dir.replace('_', ' ') pushButton.setProperty('Path', resourceDir.absolutePath() + '/' + dir) pushButton.checkable = True pushButton.connect('clicked()', self.onPresetSelected) pushButton.setIcon(qt.QIcon(os.path.join(iconsPath, dir))) pushButton.setIconSize(qt.QSize(75, 75)) self.PresetButtons.append(pushButton) self.get('InitialCollapsibleGroupBox').layout().addWidget(pushButton)
def _dialogIcon(icon): s = slicer.app.style() i = s.standardIcon(icon) return i.pixmap(qt.QSize(64, 64))
def createWindows(self): self.stereoMode = self.stereoCheckBox.isChecked() # Create widgets to hold windows self.leftWidgets = qt.QWidget() self.leftWidgets.setWindowTitle("SlicerCubeMap - Left") leftWidgetsLayout = qt.QHBoxLayout() leftWidgetsLayout.setSpacing(0) leftWidgetsLayout.setContentsMargins(0,0,0,0) self.leftWidgets.setLayout(leftWidgetsLayout) self.rightWidgets = qt.QWidget() self.rightWidgets.setWindowTitle("SlicerCubeMap - Right") rightWidgetsLayout = qt.QHBoxLayout() rightWidgetsLayout.setSpacing(0) rightWidgetsLayout.setContentsMargins(0,0,0,0) self.rightWidgets.setLayout(rightWidgetsLayout) # Per cube face per eye leftFaces = ["lpx", "lnz", "lnx", "lpz", "lpy", "lny"] rightFaces = ["rpx", "rnz", "rnx", "rpz", "rpy", "rny"] slicer.mrmlScene.AddNode(slicer.vtkMRMLViewNode()) # There's some wonky behaviour with the first view node created (ViewNode2?), so this terrible thing exists for now for face in leftFaces: # Initialize View Nodes view = slicer.vtkMRMLViewNode() slicer.mrmlScene.AddNode(view) self.cubeFaceViewNodes.append(view) # Initialize ThreeD Widgets threeDWidget = slicer.qMRMLThreeDWidget() threeDWidget.setFixedSize(qt.QSize(600, 600)) threeDWidget.setMRMLViewNode(view) threeDWidget.setMRMLScene(slicer.mrmlScene) threeDWidget.setWindowTitle("SlicerCubeMap - " + face) threeDWidget.children()[1].hide() # Hide widget controller bar; TODO: maybe a bit more robust self.cubeFaceThreeDWidgets[face] = threeDWidget # Set Stereo settings if (self.stereoCheckBox.isChecked()): threeDWidget.threeDView().renderWindow().StereoRenderOn() threeDWidget.threeDView().renderWindow().SetStereoTypeToLeft() threeDWidget.threeDView().renderWindow().Render() # Add to Left eye cubemap widget self.leftWidgets.layout().addWidget(threeDWidget) if (self.stereoMode is True): for face in rightFaces: # Initialize View Nodes view = slicer.vtkMRMLViewNode() slicer.mrmlScene.AddNode(view) self.cubeFaceViewNodes.append(view) # Initialize ThreeD Widgets threeDWidget = slicer.qMRMLThreeDWidget() threeDWidget.setFixedSize(qt.QSize(600, 600)) threeDWidget.setMRMLViewNode(view) threeDWidget.setMRMLScene(slicer.mrmlScene) threeDWidget.setWindowTitle("SlicerCubeMap - " + face) threeDWidget.children()[1].hide() # Hide widget controller bar; TODO: maybe a bit more robust self.cubeFaceThreeDWidgets[face] = threeDWidget # Set Stereo settings threeDWidget.threeDView().renderWindow().StereoRenderOn() threeDWidget.threeDView().renderWindow().SetStereoTypeToRight() threeDWidget.threeDView().renderWindow().Render() # Add to Right eye cubemap widget self.rightWidgets.layout().addWidget(threeDWidget) # Set background colors depending on face # Front, Left, Right, and Back retain default color gradient # Top and Bottom have opposite sides of the gradient self.cubeFaceThreeDWidgets["lny"].threeDView().setBackgroundColor(qt.QColor(193, 195, 232)) self.cubeFaceThreeDWidgets["lny"].threeDView().setBackgroundColor2(qt.QColor(193, 195, 232)) self.cubeFaceThreeDWidgets["lpy"].threeDView().setBackgroundColor(qt.QColor(116, 120, 190)) self.cubeFaceThreeDWidgets["lpy"].threeDView().setBackgroundColor2(qt.QColor(116, 120, 190)) if (self.stereoMode is True): self.cubeFaceThreeDWidgets["rny"].threeDView().setBackgroundColor(qt.QColor(193, 195, 232)) self.cubeFaceThreeDWidgets["rny"].threeDView().setBackgroundColor2(qt.QColor(193, 195, 232)) self.cubeFaceThreeDWidgets["rpy"].threeDView().setBackgroundColor(qt.QColor(116, 120, 190)) self.cubeFaceThreeDWidgets["rpy"].threeDView().setBackgroundColor2(qt.QColor(116, 120, 190))
def BUTTON_SIZE_SMALL(self): return qt.QSize(28, 28)
def BUTTON_SIZE_MED(self): return qt.QSize(45, 45)
def setup(self): """Init the widget """ # ScriptedLoadableModuleWidget.setup(self) settings = qt.QSettings() if (SlicerUtil.IsDevelopment): # reload button self.reloadButton = qt.QPushButton("Reload") self.reloadButton.toolTip = "Reload this module." self.reloadButton.name = "Reload" self.layout.addWidget(self.reloadButton) self.reloadButton.connect('clicked()', self.onBtnReloadClicked) self.logic = PicasaSnapLogic() self.__addObservers__() ######## Credentials self.credentialsCollapsibleButton = ctk.ctkCollapsibleButton() self.credentialsCollapsibleButton.text = "Credentials" self.layout.addWidget(self.credentialsCollapsibleButton) self.credentialsLayout = qt.QFormLayout( self.credentialsCollapsibleButton) self.isUserLogged = False self.loginLineEdit = qt.QLineEdit() self.credentialsLayout.addRow("Login: "******"Password: "******"Remember my credentials") self.rememberCredentialsCheckBox.toolTip = "Check for an automatic login when the application starts" self.loginButton = qt.QPushButton("Login") self.loginButton.toolTip = "Login in Picassa service (Google credentials)" self.logoutButton = qt.QPushButton("Logout") self.logoutButton.toolTip = "Logout to connect with another user's credentials" # Add all the items, they will be shown/hidden in refreshCredentialsUI function self.credentialsLayout.addRow(self.rememberCredentialsCheckBox, self.loginButton) self.credentialsLayout.addRow(None, self.logoutButton) ######## Snapshots (main frame) self.mainCollapsibleButton = ctk.ctkCollapsibleButton() self.mainCollapsibleButton.text = "Snapshots" self.layout.addWidget(self.mainCollapsibleButton) self.mainLayout = qt.QVBoxLayout(self.mainCollapsibleButton) ############### Current snapshots self.currentSnapshotsFrame = qt.QFrame() self.currentSnapshotsLayout = qt.QVBoxLayout() self.currentSnapshotsFrame.setLayout(self.currentSnapshotsLayout) self.currentSnapshotsFrame.setFrameShape(qt.QFrame.StyledPanel) self.mainLayout.addWidget(self.currentSnapshotsFrame) self.snapshotsLabel = qt.QLabel("Snapshots to upload:") self.snapshotsLabel.setStyleSheet( "font-weight:bold; font-size:14px; margin-bottom:10px") self.currentSnapshotsLayout.addWidget(self.snapshotsLabel) # Subframe that contains the checkbox list self.currentSnapshotsInnerFrame = qt.QFrame() self.currentSnapshotsInnerLayout = qt.QVBoxLayout() self.currentSnapshotsInnerFrame.setLayout( self.currentSnapshotsInnerLayout) self.currentSnapshotsLayout.addWidget(self.currentSnapshotsInnerFrame) self.noItemsLabel = qt.QLabel( "(There are not any snapshots at the moment)") # Add the label by default. It will be hidden if there is any snapshot self.currentSnapshotsInnerLayout.addWidget(self.noItemsLabel) self.loadExistingSnapshotsFirstLoad() ############### Albums # Try to login before getting the albums self.login() msgBox = None if self.isUserLogged: # Show message box while loading the data msgBox = qt.QMessageBox(qt.QMessageBox.Information, 'Login', 'Connecting with Picasa. Please wait...', qt.QMessageBox.Cancel) msgBox.show() try: self.albumNameFrame = qt.QFrame() self.albumNameLayout = qt.QHBoxLayout() self.albumNameFrame.setLayout(self.albumNameLayout) self.albumNameFrame.setFrameShape(qt.QFrame.StyledPanel) self.albumNameLabel = qt.QLabel("Album name:") self.albumNameLabel.setStyleSheet("font-weight:bold;") self.albumNamesComboBox = qt.QComboBox() self.loadAlbums() self.albumNameLayout.addWidget(self.albumNameLabel) self.albumNameLayout.addWidget(self.albumNamesComboBox) self.mainLayout.addWidget(self.albumNameFrame) ############### Tags self.tagsFrame = qt.QFrame() self.tagsLayout = qt.QGridLayout() self.tagsFrame.setLayout(self.tagsLayout) self.tagsFrame.setFrameShape(qt.QFrame.StyledPanel) self.tagsLabel = qt.QLabel( "Tags (select all that apply, you can filter o create new tags):" ) self.tagsLabel.setStyleSheet( "font-weight: bold; margin-bottom: 10px; margin-top: 5px") self.tagsLayout.addWidget(self.tagsLabel, 0, 0, 1, 3) # Add input to filter tags and button to add a new one self.tagsFilterLineEdit = qt.QLineEdit() self.tagsFilterLineEdit.toolTip = "Type here to filter your tags. If you press the return key all the visible tags will be checked" #self.tagsFilterLineEdit.setStyleSheet(style) self.tagsLayout.addWidget(self.tagsFilterLineEdit, 1, 0, 1, 2) self.newTagButton = qt.QPushButton("New tag") #self.newTagButton.setStyleSheet("background-color: #5D74C6; color:white") self.newTagButton.setIconSize(qt.QSize(20, 20)) self.newTagButton.setIcon( qt.QIcon(self.CIP_ICON_DIR + "/Plus - 48.png")) self.newTagButton.setFixedWidth(75) self.newTagButton.toolTip = "Add a new tag (the tag will not be created until you upload any picture with it)" self.tagsLayout.addWidget(self.newTagButton, 1, 2) self.loadTags() ############### Upload snapshots controls self.uploadSnapsButtonFrame = qt.QFrame() self.uploadSnapsLayout = qt.QHBoxLayout() self.uploadSnapsButtonFrame.setLayout(self.uploadSnapsLayout) #self(qt.QFrame.HLine) self.mainLayout.addWidget(self.uploadSnapsButtonFrame) self.uploadSnapshotsButton = qt.QPushButton() self.uploadSnapshotsButton.text = "Upload to Picasa!" self.uploadSnapshotsButton.toolTip = "Upload selected screenshots to Picassa" self.uploadSnapshotsButton.setStyleSheet( "background-color: #5D74C6; color: white; font-weight: bold; font-size:14px" ) self.uploadSnapshotsButton.setIcon( qt.QIcon(self.CIP_ICON_DIR + "/Upload - 64.png")) self.uploadSnapshotsButton.setIconSize(qt.QSize(24, 24)) self.uploadSnapshotsButton.setFixedSize(170, 35) self.uploadSnapsLayout.addWidget(self.uploadSnapshotsButton) ############### Progress bar self.progressBar = qt.QProgressDialog() self.progressBar.setMinimum(0) self.progressBar.setMinimumDuration(0) self.progressBar.setWindowModality(True) # Check for updates in CIP #autoUpdate = SlicerUtil.settingGetOrSetDefault("PicasaSnap", "AutoUpdate", 1) #uw = AutoUpdateWidget(parent=self.parent, autoUpdate=autoUpdate) #uw.addAutoUpdateCheckObserver(self.onAutoUpdateStateChanged) # self.uploadProgressFrame = qt.QFrame() # self.uploadProgressLayout = qt.QVBoxLayout() # self.uploadProgressFrame.setLayout(self.uploadProgressLayout) # # # Gif image # self.imUploading = qt.QMovie("%s/loading.gif" % self.CIP_ICON_DIR, qt.QByteArray()) # # Label to contain the gif # self.lblImLoading = qt.QLabel() # # Fix the dimensions of the image (by fixing the dimensions of the label that contains it) # self.lblImLoading.setFixedWidth(40) # # Other image parameters # self.imUploading.setCacheMode(qt.QMovie.CacheAll) # self.imUploading.setSpeed(100) # # Assign the label to the image (don't start it yet, it will be started when we are uploading) # self.lblImLoading.setMovie(self.imUploading) # #self.imUploading.start() # self.uploadProgressLayout.addWidget(self.lblImLoading) # # # Label that will show the progress # self.lblUploading = qt.QLabel("Uploading %i/%i images...") # self.uploadProgressLayout.addWidget(self.lblUploading) # # Cancel uploading button # self.btnCancelUpload = qt.QPushButton("Cancel") # self.btnCancelUpload.toolTip = "Cancel the process" # self.btnCancelUpload.setFixedWidth(100) # self.uploadProgressLayout.addWidget(self.btnCancelUpload) # self.mainLayout.addWidget(self.uploadProgressFrame) # # # Hide the progress frame # self.uploadProgressFrame.hide() ######## Connections self.uploadSnapshotsButton.connect( 'clicked (bool)', self.onUploadSnapshotsButtonClicked) self.loginButton.connect('clicked (bool)', self.onLoginButtonClicked) self.logoutButton.connect('clicked (bool)', self.onLogoutButtonClicked) self.loginLineEdit.returnPressed.connect( self.onLoginPasswordReturnKeyPressed) self.passwordLineEdit.returnPressed.connect( self.onLoginPasswordReturnKeyPressed) self.albumNamesComboBox.connect("currentIndexChanged (int)", self.onAlbumsCurrentIndexChanged) self.newTagButton.connect('clicked (bool)', self.onNewTagButtonClicked) self.tagsFilterLineEdit.connect('textEdited (QString)', self.onFilterTagsEdited) self.tagsFilterLineEdit.returnPressed.connect( self.onFilterTagsReturnKeyPressed) # Add vertical spacer self.layout.addStretch(1) finally: # Hide MesageBox if it was visible if msgBox: msgBox.close()
def sizeProbe(self, iters=10, minSize=500, maxSize=2000, step=100): for dim in xrange(minSize, maxSize, step): mainWindow().size = qt.QSize(dim, dim) self.reslicing(iters)
def setup(self): # Instantiate and connect widgets ... # reload button # (use this during development, but remove it when delivering # your module to users) self.reloadButton = qt.QPushButton("Reload") self.reloadButton.toolTip = "Reload this module." self.reloadButton.name = "MurineTrial Reload" self.layout.addWidget(self.reloadButton) self.reloadButton.connect('clicked()', self.onReload) # reload and test button # (use this during development, but remove it when delivering # your module to users) self.reloadAndTestButton = qt.QPushButton("Reload and Test") self.reloadAndTestButton.toolTip = "Reload this module and then run the self tests." self.layout.addWidget(self.reloadAndTestButton) self.reloadAndTestButton.connect('clicked()', self.onReloadAndTest) # Collapsible button measurementsCollapsibleButton = ctk.ctkCollapsibleButton() measurementsCollapsibleButton.text = "Materials" self.layout.addWidget(measurementsCollapsibleButton) # Layout within the measurements collapsible button measurementsFormLayout = qt.QFormLayout(measurementsCollapsibleButton) # list of materials in the trial measurementsFormLayout.addWidget(qt.QLabel("Individual Segmentations")) self.materialsScrollArea = qt.QScrollArea() measurementsFormLayout.addWidget(self.materialsScrollArea) self.materialsListWidget = qt.QListWidget() self.materialsScrollArea.setWidget(self.materialsListWidget) self.materialsScrollArea.setWidgetResizable(True) self.materialsListWidget.setProperty( 'SH_ItemView_ActivateItemOnSingleClick', 1) self.materialsListWidget.connect('activated(QModelIndex)', self.onMaterialActivated) # populate it materialKeys = self.logic.materials.keys() materialKeys.sort() for materialKey in materialKeys: self.materialsListWidget.addItem(materialKey) # list of sampleIDs in the trial measurementsFormLayout.addWidget( qt.QLabel("Segmentation Comparisions")) self.sampleIDsScrollArea = qt.QScrollArea() measurementsFormLayout.addWidget(self.sampleIDsScrollArea) self.sampleIDsListWidget = qt.QListWidget() self.sampleIDsScrollArea.setWidget(self.sampleIDsListWidget) self.sampleIDsScrollArea.setWidgetResizable(True) self.sampleIDsListWidget.setProperty( 'SH_ItemView_ActivateItemOnSingleClick', 1) self.sampleIDsListWidget.connect('activated(QModelIndex)', self.onSampleIDActivated) # populate it for sampleID in self.logic.gigSegComparisonSampleIDs(): self.sampleIDsListWidget.addItem(sampleID) # list of retestIDs in the trial measurementsFormLayout.addWidget(qt.QLabel("Repeatability Tests")) self.retestIDsScrollArea = qt.QScrollArea() measurementsFormLayout.addWidget(self.retestIDsScrollArea) self.retestIDsListWidget = qt.QListWidget() self.retestIDsScrollArea.setWidget(self.retestIDsListWidget) self.retestIDsScrollArea.setWidgetResizable(True) self.retestIDsListWidget.setProperty( 'SH_ItemView_ActivateItemOnSingleClick', 1) self.retestIDsListWidget.connect('activated(QModelIndex)', self.onRetestActivated) # populate it for retestID in self.logic.retestComparisonSampleIDs(): self.retestIDsListWidget.addItem(retestID) # process all button processAllButton = qt.QPushButton("Process All") processAllButton.toolTip = "Loads all subjecs at all timepoints." measurementsFormLayout.addWidget(processAllButton) processAllButton.connect('clicked(bool)', self.logic.processAll) # results area self.resultsView = qt.QWebView() self.resultsView.minimumSize = qt.QSize(100, 100) policy = qt.QSizePolicy() policy.setHorizontalPolicy(qt.QSizePolicy.Ignored) self.resultsView.setSizePolicy(policy) self.layout.addWidget(self.resultsView) # Add vertical spacer self.layout.addStretch(1)
def construct(self): """ Constructs the MetadataEditorSet widget. """ #-------------------- # Loop through all folders as per # Xnat.path.DEFAULT_LEVELS. We create an AnimatedCollapsible # for every folder, one MetadataEditor_Custom and one # MetadataEditor_Default, along with the relevant buttons for # very folder in XNAT_LEVELS. #-------------------- for xnatLevel in Xnat.path.DEFAULT_LEVELS: # # Set DEFAULT label per xnat level. # self.labels[xnatLevel] = [] self.labels[xnatLevel].append(qt.QLabel('<b>DEFAULT<b>')) self.labels[xnatLevel][0].setFont( XnatSlicerGlobals.LABEL_FONT_BOLD) # # Set the collapsible's internal layout # (a qt.QGridLayout) per folder. # self.collapsibleLayouts[xnatLevel] = qt.QGridLayout() self.collapsibleLayouts[xnatLevel].\ addWidget(self.labels[xnatLevel][0], 0, 0) # # Set the MetadataEditor_Default, # add to layout. # self.defaultMetadataEditors[xnatLevel] = \ MetadataEditor_Default(xnatLevel) self.collapsibleLayouts[xnatLevel].\ addWidget(self.defaultMetadataEditors[xnatLevel], 1, 0) # # Set the MetadataEditor_Custom, # add to layout. # self.customMetadataEditors[xnatLevel] = \ MetadataEditor_Custom(xnatLevel) self.collapsibleLayouts[xnatLevel].\ addWidget(self.customMetadataEditors[xnatLevel], 1, 1, 1, 2) # # Set DEFAULT label per xnat level. # self.labels[xnatLevel].append(qt.QLabel('<b>CUSTOM<b>')) self.labels[xnatLevel][1].setFont( XnatSlicerGlobals.LABEL_FONT_BOLD) self.collapsibleLayouts[xnatLevel].\ addWidget(self.labels[xnatLevel][1], 0, 1) # # Add the 'editCustom' button. # # NOTE: The user can choose to hide/show these buttons, # based on what's needed. For isntance, the Settings['METADATA'] # class hides these buttons as they are not necessary for # its workflow. # self.editCustomButtons[xnatLevel] = \ XnatSlicerUtils.generateButton(iconOrLabel = \ "Edit custom tags for '%s'"%(xnatLevel), toolTip = "Adds a custom metadata tag to display in the" + " 'Info' column.", font = XnatSlicerGlobals.LABEL_FONT, size = qt.QSize(180, 20), enabled = True) self.collapsibleLayouts[xnatLevel].\ addWidget(self.editCustomButtons[xnatLevel], 0, 2) self.editCustomButtonGroup.\ addButton(self.editCustomButtons[xnatLevel]) # # Put all of the widgets into first, a contentsWidget. # Then set the widget of the AnimatedCollapsible to the # contentsWidget. # self.collapsibles[xnatLevel] = AnimatedCollapsible(self, \ xnatLevel.title()) self.collapsibles[xnatLevel].setMaxExpandedHeight(250) self.collapsibles[xnatLevel].setMinExpandedHeight(250) contentsWidget = qt.QWidget() contentsWidget.setLayout(self.collapsibleLayouts[xnatLevel]) self.collapsibles[xnatLevel].setContents(contentsWidget) self.collapsibles[xnatLevel].setFixedWidth(550) # # Add collapsible to self.mainLayout. # self.mainLayout.addWidget(self.collapsibles[xnatLevel]) self.mainLayout.addSpacing(10) #-------------------- # Set callback to Update XNATSlicer's # layout when animating. #-------------------- for key, collapsible in self.collapsibles.items(): collapsible.onEvent('animate', self.updateLayout) #-------------------- # Set mainLayout to the master layout. #-------------------- self.mainLayout.addStretch() self.setLayout(self.mainLayout) #-------------------- # Set the current item tyype to label. # The user can change it to 'checkbox' # later. #-------------------- self.setItemType('label')
def __init__(self, MODULE): """ Init function. """ #-------------------------------- # Call parent __init__ #-------------------------------- super(XnatSearchBar, self).__init__(self) #-------------------------------- # Class vars. #-------------------------------- self.MODULE = MODULE self.prevText = None self.defaultSearchText = 'Search projects, subjects and experiments...' #-------------------------------- # The search box (qt.QLineEdit) #-------------------------------- self.searchLine = qt.QLineEdit() #-------------------------------- # The search button #-------------------------------- self.button = qt.QPushButton('') self.button.setIcon( qt.QIcon( os.path.join(self.MODULE.GLOBALS.LOCAL_URIS['icons'], 'x.png'))) size = qt.QSize(26, 26) self.button.setFixedSize(size) self.button.connect('clicked()', self.onClearButtonClicked) #-------------------------------- # Search Layout #-------------------------------- self.searchLayout = qt.QHBoxLayout() self.searchLayout.addWidget(self.searchLine) self.searchLayout.addWidget(self.button) #-------------------------------- # Set the layout. #-------------------------------- self.setLayout(self.searchLayout) #-------------------------------- # AESTHETICS #-------------------------------- # # Widget aesthetics # self.setStyleSheet( 'border: 1px solid rgb(160,160,160); border-radius: 3px;') self.setFixedHeight(22) # # Search box aesthetics # self.searchLine.setStyleSheet("border: none") # # Button aesthetics # self.button.setStyleSheet("border: none") self.button.setFixedHeight(20) # # Layout aesthetics # self.searchLayout.setContentsMargins(0, 0, 0, 0) #-------------------------------- # Event filter (for clearing and # inputting default text). #-------------------------------- self.searchLine.installEventFilter(self) #-------------------------------- # Clear the search line at first. #-------------------------------- self.onClearButtonClicked()
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)
def __init__(self, xnatLevel): """ Init function. In addtion to the MODULE, the user must also provide the xnatLevel that the editor applies to. """ #-------------------- # Parent init. #-------------------- qt.QFrame.__init__(self) self.EVENT_TYPES = list( set(MetadataEditor.EVENT_TYPES + self.EVENT_TYPES)) self.Events = MokaUtils.Events(self.EVENT_TYPES) #-------------------- # Class variables. #-------------------- self.xnatLevel = xnatLevel self.onMetadataCheckedTag = "ON_METADATA_CHECKED" #-------------------- # The list widget. #-------------------- self.listWidget = VariableItemListWidget() self.listWidget.setStyleSheet('margin-top: 0px; margin-bottom: 0px') # # Connect item click event. # self.listWidget.connect('itemClicked(QListWidgetItem *)', self.onItemClicked) #-------------------- # The main layout of the widget. #-------------------- self.mainLayout = qt.QVBoxLayout() self.mainLayout.addWidget(self.listWidget) self.setLayout(self.mainLayout) #-------------------- # Widget item size. #-------------------- self.itemSize = qt.QSize(20, 20) #-------------------- # Call setup function: # this is a to be inherited # by child classes. #-------------------- self.setup() #-------------------- # List items are defaulted to # 'label'. The user can change # the item type after initialization. #-------------------- self.setItemType('label') #-------------------- # Sync list contents with the # the metadata stored in the # SettingsFile. #-------------------- self.update()
def setup(self): """This is called one time when the module GUI is initialized """ ScriptedLoadableModuleWidget.setup(self) # Create objects that can be used anywhere in the module. Example: in most cases there should be just one # object of the logic class self.logic = CIP_PAARatioLogic() # # Create all the widgets. Example Area mainAreaCollapsibleButton = ctk.ctkCollapsibleButton() mainAreaCollapsibleButton.text = "Main parameters" self.layout.addWidget(mainAreaCollapsibleButton) self.mainAreaLayout = qt.QGridLayout(mainAreaCollapsibleButton) self.label = qt.QLabel("Select the volume") self.label.setStyleSheet("margin:10px 0 20px 7px") self.mainAreaLayout.addWidget(self.label, 0, 0) self.volumeSelector = slicer.qMRMLNodeComboBox() self.volumeSelector.nodeTypes = ("vtkMRMLScalarVolumeNode", "") # DEPRECATED. Now there is a new vtkMRMLLabelMapNode #self.volumeSelector.addAttribute( "vtkMRMLScalarVolumeNode", "LabelMap", "0" ) # No labelmaps self.volumeSelector.selectNodeUponCreation = True self.volumeSelector.autoFillBackground = True self.volumeSelector.addEnabled = True self.volumeSelector.noneEnabled = False self.volumeSelector.removeEnabled = False self.volumeSelector.showHidden = False self.volumeSelector.showChildNodeTypes = False self.volumeSelector.setMRMLScene(slicer.mrmlScene) self.volumeSelector.setStyleSheet( "margin:0px 0 0px 0; padding:2px 0 2px 5px") self.mainAreaLayout.addWidget(self.volumeSelector, 0, 1) # self.label2 = qt.QLabel("Select the slice") # self.label2.setStyleSheet("margin:0px 0 20px 7px; padding-top:20px") # self.mainAreaLayout.addWidget(self.label2, 1, 0) self.placeDefaultRulersButton = ctk.ctkPushButton() self.placeDefaultRulersButton.text = "Place default rulers" # self.placeDefaultRulersSliceButton.toolTip = "Navigate to the best estimated slice to place the rulers" self.placeDefaultRulersButton.setIcon( qt.QIcon("{0}/next.png".format(SlicerUtil.CIP_ICON_DIR))) self.placeDefaultRulersButton.setIconSize(qt.QSize(20, 20)) self.placeDefaultRulersButton.setStyleSheet("font-weight: bold;") # self.placeDefaultRulersButton.setFixedWidth(140) self.mainAreaLayout.addWidget(self.placeDefaultRulersButton, 1, 1) ### Structure Selector self.structuresGroupbox = qt.QGroupBox("Select the structure") self.groupboxLayout = qt.QVBoxLayout() self.structuresGroupbox.setLayout(self.groupboxLayout) self.mainAreaLayout.addWidget(self.structuresGroupbox, 2, 0) self.structuresButtonGroup = qt.QButtonGroup() # btn = qt.QRadioButton("None") # btn.visible = False # self.structuresButtonGroup.addButton(btn) # self.groupboxLayout.addWidget(btn) btn = qt.QRadioButton("Both") btn.checked = True self.structuresButtonGroup.addButton(btn, 0) self.groupboxLayout.addWidget(btn) btn = qt.QRadioButton("Pulmonary Arterial") self.structuresButtonGroup.addButton(btn, 1) self.groupboxLayout.addWidget(btn) btn = qt.QRadioButton("Aorta") self.structuresButtonGroup.addButton(btn, 2) self.groupboxLayout.addWidget(btn) ### Buttons toolbox self.buttonsToolboxFrame = qt.QFrame() self.buttonsToolboxLayout = qt.QGridLayout() self.buttonsToolboxFrame.setLayout(self.buttonsToolboxLayout) self.mainAreaLayout.addWidget(self.buttonsToolboxFrame, 2, 1) self.placeRulersButton = ctk.ctkPushButton() self.placeRulersButton.text = "Place ruler/s" self.placeRulersButton.toolTip = "Place the ruler/s for the selected structure/s in the current slice" self.placeRulersButton.setIcon( qt.QIcon("{0}/ruler.png".format(SlicerUtil.CIP_ICON_DIR))) self.placeRulersButton.setIconSize(qt.QSize(20, 20)) self.placeRulersButton.setFixedWidth(105) self.placeRulersButton.setStyleSheet("font-weight:bold") self.buttonsToolboxLayout.addWidget(self.placeRulersButton, 0, 0) self.moveUpButton = ctk.ctkPushButton() self.moveUpButton.text = "Move up" self.moveUpButton.toolTip = "Move the selected ruler/s one slice up" self.moveUpButton.setIcon( qt.QIcon("{0}/move_up.png".format(SlicerUtil.CIP_ICON_DIR))) self.moveUpButton.setIconSize(qt.QSize(20, 20)) self.moveUpButton.setFixedWidth(95) self.buttonsToolboxLayout.addWidget(self.moveUpButton, 0, 1) self.moveDownButton = ctk.ctkPushButton() self.moveDownButton.text = "Move down" self.moveDownButton.toolTip = "Move the selected ruler/s one slice down" self.moveDownButton.setIcon( qt.QIcon("{0}/move_down.png".format(SlicerUtil.CIP_ICON_DIR))) self.moveDownButton.setIconSize(qt.QSize(20, 20)) self.moveDownButton.setFixedWidth(95) self.buttonsToolboxLayout.addWidget(self.moveDownButton, 0, 2) self.removeButton = ctk.ctkPushButton() self.removeButton.text = "Remove ALL rulers" self.removeButton.toolTip = "Remove all the rulers for this volume" self.removeButton.setIcon( qt.QIcon("{0}/delete.png".format(SlicerUtil.CIP_ICON_DIR))) self.removeButton.setIconSize(qt.QSize(20, 20)) self.buttonsToolboxLayout.addWidget(self.removeButton, 1, 1, 1, 2, 2) ### Textboxes self.textboxesFrame = qt.QFrame() self.textboxesLayout = qt.QFormLayout() self.textboxesFrame.setLayout(self.textboxesLayout) self.textboxesFrame.setFixedWidth(190) self.mainAreaLayout.addWidget(self.textboxesFrame, 3, 0) self.paTextBox = qt.QLineEdit() self.paTextBox.setReadOnly(True) self.textboxesLayout.addRow("PA (mm): ", self.paTextBox) self.aortaTextBox = qt.QLineEdit() self.aortaTextBox.setReadOnly(True) self.textboxesLayout.addRow("Aorta (mm): ", self.aortaTextBox) self.ratioTextBox = qt.QLineEdit() self.ratioTextBox.setReadOnly(True) self.textboxesLayout.addRow("Ratio PA/A: ", self.ratioTextBox) # Save case data self.reportsCollapsibleButton = ctk.ctkCollapsibleButton() self.reportsCollapsibleButton.text = "Reporting" self.layout.addWidget(self.reportsCollapsibleButton) self.reportsLayout = qt.QHBoxLayout(self.reportsCollapsibleButton) self.storedColumnNames = [ "caseId", "paDiameter_mm", "aortaDiameter_mm", "pa1r", "pa1a", "pa1s", "pa2r", "pa2a", "pa2s", "a1r", "a1a", "a1s", "a2r", "a2a", "a2s" ] self.reportsWidget = CaseReportsWidget( "CIP_PAARatio", columnNames=self.storedColumnNames, parentWidget=self.reportsCollapsibleButton) self.reportsWidget.setup() self.switchToRedView() ##### # Case navigator if SlicerUtil.isSlicerACILLoaded(): caseNavigatorAreaCollapsibleButton = ctk.ctkCollapsibleButton() caseNavigatorAreaCollapsibleButton.text = "Case navigator" self.layout.addWidget(caseNavigatorAreaCollapsibleButton, 0x0020) # caseNavigatorLayout = qt.QVBoxLayout(caseNavigatorAreaCollapsibleButton) # Add a case list navigator from ACIL.ui import CaseNavigatorWidget self.caseNavigatorWidget = CaseNavigatorWidget( self.moduleName, caseNavigatorAreaCollapsibleButton) self.caseNavigatorWidget.setup() self.layout.addStretch() # Connections self.observers = [] self.__addSceneObservables__() self.volumeSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onVolumeSelectorChanged) self.placeDefaultRulersButton.connect('clicked()', self.oPlaceDefaultRulersClicked) self.placeRulersButton.connect('clicked()', self.onPlaceRulersClicked) self.moveUpButton.connect('clicked()', self.onMoveUpRulerClicked) self.moveDownButton.connect('clicked()', self.onMoveDownRulerClicked) self.removeButton.connect('clicked()', self.onRemoveRulerClicked) self.reportsWidget.addObservable( self.reportsWidget.EVENT_SAVE_BUTTON_CLICKED, self.onSaveReport)
def makeButtons(hostEditor): """ As described. """ addButton = hostEditor.MODULE.utils.generateButton(iconOrLabel = 'Add', toolTip = "Need tool-tip.", font = hostEditor.MODULE.GLOBALS.LABEL_FONT, size = qt.QSize(90, 20), enabled = True) editButton = hostEditor.MODULE.utils.generateButton(iconOrLabel = 'Edit', toolTip = "Need tool-tip.", font = hostEditor.MODULE.GLOBALS.LABEL_FONT, size = qt.QSize(90, 20), enabled = True) deleteButton = hostEditor.MODULE.utils.generateButton(iconOrLabel = 'Delete', toolTip = "Need tool-tip.", font = hostEditor.MODULE.GLOBALS.LABEL_FONT, size = qt.QSize(90, 20), enabled = True) deleteButton.setEnabled(False) editButton.setEnabled(False) return addButton, editButton, deleteButton
def setChecked(self, toggled, animDuration=None): """ Constructs an executes an animation for the widget once the title button is toggled. """ #---------------- # We need to set the button state in case # this method is programatically called. #---------------- self.toggleButton.setChecked(toggled) #---------------- # Track whether collapsible was toggled. #---------------- self.toggled = toggled #---------------- # Define the animation duration. #---------------- if not animDuration: animDuration = self.animDuration #---------------- # Clear animation #---------------- self.animations.clear() #---------------- # For safety, set the width of # the widget to '100%' #---------------- self.setStyleSheet('width: 100%') #---------------- # Modify button text to match the toggled # state (down arrow or right arrow) #---------------- self.configureButton(toggled) #---------------- # Make the animation object #---------------- anim = qt.QPropertyAnimation(self, 'size') #---------------- # Set the duration #---------------- anim.setDuration(animDuration) #---------------- # Set the easing curve #---------------- anim.setEasingCurve(self.easingCurve) #---------------- # Set the start/end values depending on # the toggle state. #---------------- if self.toggled: # # Establish the 'toggled'/expanded animation sizes. # startSize = qt.QSize(self.geometry.width(), self.collapsedHeight) endSize = qt.QSize(self.geometry.width(), self.maxHeight) self.setMaximumHeight(self.collapsedHeight) self.setMinimumHeight(self.collapsedHeight) else: # # Establish the 'untoggled'/collapsed animation sizes. # startHeight = self.geometry.height() startSize = qt.QSize(self.geometry.width(), startHeight) endSize = qt.QSize(self.geometry.width(), self.collapsedHeight) self.setMaximumHeight(startHeight) self.setMinimumHeight(startHeight) # # Hide the internal contents for better # visual clarity. # self.hideContentsWidgets() #---------------- # Set the start/end animation values. #---------------- anim.setStartValue(startSize) anim.setEndValue(endSize) #---------------- # Set callback during animation. #---------------- anim.valueChanged.connect(self.onAnimateMain) #---------------- # Connect the 'finished()' signal of the animation # to the finished callback... #---------------- anim.connect('finished()', self.onAnimationFinished) #---------------- # Add main animation to queue and # start animation. #---------------- self.animations.addAnimation(anim) self.animations.start()
def setup(self, moduleName="", labelmapNodeNameExtensions=defaultLabelmapNodeNameExtensions, volumesFileExtensions=defaultVolumesFileExtensions, iconsPath=None): """Setup the widget with the desride options. Defaults: - moduleName = "" --> used just to set the settings (for instance the last directory that was opened in the module). - labelmapNodeNameExtensions = ["_partialLung", "_bodyComposition"] --> node names that will be used to identify a label map - volumesFileExtensions = [".nhdr", ".nrrd"] --> extensions of the files that will be allowed to be loaded. The first item will be used to save new label maps """ settings = slicer.app.settings() try: self.IsDevelopment = settings.value( 'Developer/DeveloperMode').lower() == 'true' except: self.IsDevelopment = False self.setParameters(moduleName, labelmapNodeNameExtensions, volumesFileExtensions) if not iconsPath: iconsPath = SlicerUtil.CIP_ICON_DIR #print("Imported " + iconsPath) # ctkCollapsibleButton+frame that wrap everything self.loadSaveFilesCollapsibleButton = ctk.ctkCollapsibleButton() self.loadSaveFilesCollapsibleButton.text = "Quick Load / Save data (nrrd format)" self.layout.addWidget(self.loadSaveFilesCollapsibleButton) loadSaveFilesLayout = qt.QVBoxLayout( self.loadSaveFilesCollapsibleButton) self.buttonsFrame = qt.QFrame(self.parent) self.buttonsFrame.setLayout(qt.QHBoxLayout()) # Buttons self.btnLoad = ctk.ctkPushButton() self.btnLoad.text = "Load cases" self.btnLoad.toolTip = "Load one or more cases and their bodyComposition label maps" self.btnLoad.setIcon(qt.QIcon("{0}/Load.png".format(iconsPath))) self.btnLoad.setIconSize(qt.QSize(32, 32)) self.btnSave = ctk.ctkPushButton() self.btnSave.text = "Save labelmap" self.btnSave.toolTip = "Save the current bodyComposition labelmap" self.btnSave.setIcon(qt.QIcon("{0}/Save.png".format(iconsPath))) self.btnSave.setIconSize(qt.QSize(32, 32)) self.btnSaveAll = ctk.ctkPushButton() self.btnSaveAll.text = "Save all labelmaps" self.btnSaveAll.toolTip = "Save all the opened bodyComposition labelmaps" self.btnSaveAll.setIcon(qt.QIcon("{0}/SaveAll.png".format(iconsPath))) self.btnSaveAll.setIconSize(qt.QSize(32, 32)) self.buttonsFrame.layout().addWidget(self.btnLoad) self.buttonsFrame.layout().addWidget(self.btnSave) self.buttonsFrame.layout().addWidget(self.btnSaveAll) loadSaveFilesLayout.addWidget(self.buttonsFrame) # Additional parameters # additionalParamsCollapsibleButton = ctk.ctkCollapsibleButton() # self.op = qt.QStyleOptionButton() # additionalParamsCollapsibleButton.initStyleOptions(self.op) # additionalParamsCollapsibleButton.text = "Other params" # self.layout.addWidget(additionalParamsCollapsibleButton) # aditionalParamsLayout = qt.QFormLayout(additionalParamsCollapsibleButton) # # # Chest regions combo box # self.cbFileType = qt.QComboBox(additionalParamsCollapsibleButton) # self.cbFileType.addItem("My item") # self.cbFileType.setItemData(0, "My key") # # index=0 # # for key, item in self.logic.regionTypes.iteritems(): # # self.regionComboBox.addItem(item[1]) # Add label description # # self.regionComboBox.setItemData(index, key) # Add string code # # index += 1 # aditionalParamsLayout.addRow("Select the file type ", self.cbFileType) # Connections self.btnLoad.connect('clicked()', self.onBtnLoadClicked) self.btnSave.connect('clicked()', self.onBtnSaveClicked) self.btnSaveAll.connect('clicked()', self.onBtnSaveAllClicked)
def setup(self): self.developerMode = False ScriptedLoadableModuleWidget.setup(self) annotationsCollapsibleButton = ctk.ctkCollapsibleButton() annotationsCollapsibleButton.text = "Astro Annotations" self.layout.addWidget(annotationsCollapsibleButton) # Layout within the dummy collapsible button annotationsFormLayout = qt.QVBoxLayout(annotationsCollapsibleButton) # Color horizontalLayout_1 = qt.QHBoxLayout() horizontalLayout_1.setObjectName("horizontalLayout_1") self.colorLabel = qt.QLabel() self.colorLabel.setText("Annotations color:") self.colorLabel.setFixedSize(qt.QSize(120, 30)) horizontalLayout_1.addWidget(self.colorLabel) self.colorSelector = ctk.ctkColorPickerButton() self.colorSelector.setObjectName("ColorPickerButton") sizePolicy = qt.QSizePolicy() sizePolicy.setHorizontalPolicy(qt.QSizePolicy.Expanding) sizePolicy.setVerticalPolicy(qt.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.colorSelector.sizePolicy.hasHeightForWidth()) self.colorSelector.setSizePolicy(sizePolicy) self.colorSelector.setMinimumSize(qt.QSize(0, 30)) self.colorSelector.setIconSize(qt.QSize(32, 32)) self.colorSelector.setColor(qt.QColor(255, 187, 20)) self.colorSelector.setDisplayColorName(0) horizontalLayout_1.addWidget(self.colorSelector) annotationsFormLayout.addLayout(horizontalLayout_1) # Font Style horizontalLayout_2 = qt.QHBoxLayout() horizontalLayout_2.setObjectName("horizontalLayout_2") self.fontStyleLabel = qt.QLabel() self.fontStyleLabel.setText("Font style:") self.fontStyleLabel.setFixedSize(qt.QSize(120, 30)) horizontalLayout_2.addWidget(self.fontStyleLabel) self.styleComboBox = qt.QComboBox() self.styleComboBox.addItem("Arial") self.styleComboBox.addItem("Courier") self.styleComboBox.addItem("Times") sizePolicy.setHeightForWidth( self.styleComboBox.sizePolicy.hasHeightForWidth()) self.styleComboBox.setMinimumSize(qt.QSize(0, 30)) horizontalLayout_2.addWidget(self.styleComboBox) annotationsFormLayout.addLayout(horizontalLayout_2) # Font size horizontalLayout_3 = qt.QHBoxLayout() horizontalLayout_3.setObjectName("horizontalLayout_3") self.fontSizeLabel = qt.QLabel() self.fontSizeLabel.setText("Font size:") self.fontSizeLabel.setFixedSize(qt.QSize(120, 30)) horizontalLayout_3.addWidget(self.fontSizeLabel) self.sizeSpinBox = qt.QSpinBox() sizePolicy.setHeightForWidth( self.sizeSpinBox.sizePolicy.hasHeightForWidth()) self.sizeSpinBox.setMinimumSize(qt.QSize(0, 30)) self.sizeSpinBox.minimum = 1 self.sizeSpinBox.maximum = 30 self.sizeSpinBox.setValue(12) self.sizeSpinBox.setToolTip( "This value is multiplied for 1.5 if the ruler is set to thick.") horizontalLayout_3.addWidget(self.sizeSpinBox) annotationsFormLayout.addLayout(horizontalLayout_3) verticalSpacer = qt.QSpacerItem(200, 200, qt.QSizePolicy.Minimum, qt.QSizePolicy.Expanding) self.layout.addItem(verticalSpacer) # Connections self.colorSelector.connect('colorChanged(QColor)', self.onAnnotationsColorChanged) self.styleComboBox.connect('currentTextChanged(QString)', self.onAnnotationsFontStyleChanged) self.sizeSpinBox.connect('valueChanged(int)', self.onAnnotationsFontSizeChanged)