def browse(self): directory = QtGui.QFileDialog.getExistingDirectory(self, "Select Destination Directory", self.getDestinationPathFromField()) directory = canonicalizePath(directory) if directory: self.updateComboBox(self.directoryComboBox, newValue=directory) self.directoryComboBox.setCurrentIndex(self.directoryComboBox.findText(directory)) self.updatePath(directory)
def browse(self): directory = QtGui.QFileDialog.getExistingDirectory(self, "Select Data Directory", self.directoryComboBox.itemText(self.field("dataDir"))) directory = canonicalizePath(directory) if directory: self.updateComboBox(self.directoryComboBox, newValue=directory) #self.directoryComboBox.setCurrentIndex(self.directoryComboBox.findText(directory)) self.updatePath(directory) self.updateTemplateTree()
def __init__(self, parent=None): super(ConclusionPage, self).__init__(parent) self.setTitle("Confirmation") self.state = PluginWizardGui.loadSettings() label = QtGui.QLabel("Please verify that the following info is correct. Be very conscious about " "the template path and the destination dir since no additional checks are " "performed.\n\n" "Press 'Done' to create your new plugin.") label.setWordWrap(True) self.browser = QtGui.QTextBrowser() spacer = QtGui.QSpacerItem(40, 20) browseButton = self.createButton("&Browse...", self.browse) browseButton.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Preferred) directoryLabel = QtGui.QLabel("Destination Dir:") directoryLabel.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Preferred) self.destinationPath = canonicalizePath(QtCore.QDir.homePath()) self.destinationDir = QtCore.QDir(self.destinationPath) self.directoryComboBox = self.createDirectoryComboBox(self.destinationPath) directoryComboBoxHelp = "Select a destination directory where the new plugin should be stored." self.directoryComboBox.setWhatsThis(directoryComboBoxHelp) self.directoryComboBox.setToolTip(directoryComboBoxHelp) self.overwriteCheckBox = self.createCheckBox("Overwrite?", self.updateOverwrite) overwriteCheckBoxHelp = "Check to overwrite existing plugins with the same name in the destination directory." self.overwriteCheckBox.setWhatsThis(overwriteCheckBoxHelp) self.overwriteCheckBox.setToolTip(overwriteCheckBoxHelp) mainLayout = QtGui.QVBoxLayout() mainLayout.addWidget(label) mainLayout.addItem(spacer) mainLayout.addWidget(self.browser) gridLayout = QtGui.QGridLayout() gridLayout.addItem(spacer, 0, 0) gridLayout.addWidget(directoryLabel, 1, 0) gridLayout.addWidget(self.directoryComboBox, 1, 1) gridLayout.addWidget(browseButton, 1, 2) gridLayout.addWidget(self.overwriteCheckBox, 2, 1) mainLayout.insertLayout(3, gridLayout) self.registerField("destinationPath", self.directoryComboBox) self.registerField("overwrite", self.overwriteCheckBox) self.setLayout(mainLayout)
def getPathFromDirectoryComboBox(self): try: entry = self.directoryComboBox.itemText() except TypeError: # not sure if this is wise to return current path here # if asked for the current entry; as this is technically not # the correct answer... entry = self.currentPath if os.path.exists(entry) and os.path.isdir(entry): fullpath = canonicalizePath(os.path.realpath(entry)) self.updatePath(fullpath) return fullpath return None