def promptForDatabaseDirectory(self): """Ask the user to pick a database directory. But, if the application is in testing mode, just pick a temp directory """ commandOptions = slicer.app.commandOptions() if commandOptions.testingEnabled: databaseDirectory = slicer.app.temporaryPath + '/tempDICOMDatbase' qt.QDir().mkpath(databaseDirectory) self.onDatabaseDirectoryChanged(databaseDirectory) else: settings = qt.QSettings() databaseDirectory = settings.value('DatabaseDirectory') if databaseDirectory: self.onDatabaseDirectoryChanged(databaseDirectory) else: fileDialog = ctk.ctkFileDialog(slicer.util.mainWindow()) fileDialog.setWindowModality(1) fileDialog.setWindowTitle("Select DICOM Database Directory") fileDialog.setFileMode(2) # prompt for directory fileDialog.connect('fileSelected(QString)', self.onDatabaseDirectoryChanged) label = qt.QLabel( "<p><p>The Slicer DICOM module stores a local database with an index to all datasets that are <br>pushed to slicer, retrieved from remote dicom servers, or imported.<p>Please select a location for this database where you can store the amounts of data you require.<p>Be sure you have write access to the selected directory.", fileDialog) fileDialog.setBottomWidget(label) fileDialog.exec_()
def findFile(): dialog = ctk.ctkFileDialog() if _type == 'file': selected = dialog.getOpenFileName() if _type == 'folder': selected = dialog.getExistingDirectory() if selected: self.labels[label_id].text = selected
def getPath(self): '''Choose the project folder''' dialog = ctk.ctkFileDialog() selected = dialog.getExistingDirectory() if selected: self.prjPath = selected self.setting_path = path.join(self.prjPath, 'setting') self.labPrjpath.text = '\t' + selected
def promptForDatabaseDirectory(self): fileDialog = ctk.ctkFileDialog(slicer.util.mainWindow()) fileDialog.setWindowModality(1) fileDialog.setWindowTitle("Select DICOM Database Directory") fileDialog.setFileMode(2) # prompt for directory fileDialog.connect('fileSelected(QString)', self.onDatabaseDirectoryChanged) label = qt.QLabel("<p><p>The Slicer DICOM module stores a local database with an index to all datasets that are <br>pushed to slicer, retrieved from remote dicom servers, or imported.<p>Please select a location for this database where you can store the amounts of data you require.<p>Be sure you have write access to the selected directory.", fileDialog) fileDialog.setBottomWidget(label) fileDialog.open()
def promptForDatabaseDirectory(self): fileDialog = ctk.ctkFileDialog(slicer.util.mainWindow()) fileDialog.setWindowModality(1) fileDialog.setWindowTitle("Select DICOM Database Directory") fileDialog.setFileMode(2) # prompt for directory fileDialog.connect('fileSelected(QString)', self.onDatabaseDirectoryChanged) label = qt.QLabel( "<p><p>The Slicer DICOM module stores a local database with an index to all datasets that are <br>pushed to slicer, retrieved from remote dicom servers, or imported.<p>Please select a location for this database where you can store the amounts of data you require.<p>Be sure you have write access to the selected directory.", fileDialog) fileDialog.setBottomWidget(label) fileDialog.open()
def onOpenDialogSaveJson(self): if self.verbose: print("onSave") print("Current path", self.inputJsonFn.currentPath) fileDialog = ctk.ctkFileDialog(slicer.util.mainWindow()) fileDialog.setDirectory(self.inputJsonFn.currentPath) fileDialog.setWindowModality(1) fileDialog.setWindowTitle("Select Json File") fileDialog.setFileMode(3) # prompt for files fileDialog.connect('fileSelected(QString)', self.onSaveJson) fileDialog.open() ctk.ctkFileDialog.get
def onSave(self): dlg = ctk.ctkFileDialog() CSVpath = dlg.getSaveFileName( None, "Export CSV file for Classification groups", os.path.join(qt.QDir.homePath(), "Desktop"), "CSV File (*.csv)") if CSVpath == '' or CSVpath == ' ': return if self.logic.checkExtension(CSVpath, '.csv'): print('saving ...', end=' ') self.logic.saveResults(CSVpath) slicer.util.delayDisplay("Exploration saved") print('Done!')
def promptForDatabaseDirectory(self): """Ask the user to pick a database directory. But, if the application is in testing mode, just pick a temp directory """ commandOptions = slicer.app.commandOptions() if commandOptions.testingEnabled: databaseDirectory = slicer.app.temporaryPath + '/tempDICOMDatbase' qt.QDir().mkpath(databaseDirectory) self.onDatabaseDirectoryChanged(databaseDirectory) else: settings = qt.QSettings() databaseDirectory = settings.value('DatabaseDirectory') if databaseDirectory: self.onDatabaseDirectoryChanged(databaseDirectory) else: fileDialog = ctk.ctkFileDialog(slicer.util.mainWindow()) fileDialog.setWindowModality(1) fileDialog.setWindowTitle("Select DICOM Database Directory") fileDialog.setFileMode(2) # prompt for directory fileDialog.connect('fileSelected(QString)', self.onDatabaseDirectoryChanged) label = qt.QLabel("<p><p>The Slicer DICOM module stores a local database with an index to all datasets that are <br>pushed to slicer, retrieved from remote dicom servers, or imported.<p>Please select a location for this database where you can store the amounts of data you require.<p>Be sure you have write access to the selected directory.", fileDialog) fileDialog.setBottomWidget(label) fileDialog.exec_()
def getSaveFile(): '''Choose a file''' dialog = ctk.ctkFileDialog() selected = dialog.getSaveFileName() return selected
def getPath(): '''Choose the folder''' dialog = ctk.ctkFileDialog() selected = dialog.getExistingDirectory() return selected
def getPath(self): '''Choose the project folder''' dialog = ctk.ctkFileDialog() selected = dialog.getExistingDirectory() return os.path.realpath(selected) if selected else None