def abrir_proyecto(self, parent = None, filename = None): """ Lanza el diálogo de apertura de fichero """ from Driza.excepciones import FicheroNoExisteException, FicheroErroneoException, FicheroTipoDesconocidoException if not parent: parent = self if not self.__dproyecto_modificado(): return if not filename: filtro = "" for fmt in SL.extensiones_fichero: filtro = filtro + "%s files (*.%s);;" % (fmt, fmt.lower()) filename = QFileDialog.getOpenFileName(QString.null, filtro, self, None, "Dialogo abrir fichero", "") filename = str(filename) if filename: try: self.__gestorproyectos.cargar(filename) except FicheroErroneoException: QMessageBox.warning(parent, u'Atención', 'El fichero no ha podido ser leido') except FicheroTipoDesconocidoException: QMessageBox.warning(parent, u'Atención', 'El fichero no ha podido ser leido') except FicheroNoExisteException: QMessageBox.warning(parent, u'Atención', 'El fichero no ha podido ser leido') except AttributeError: QErrorMessage(parent, "Error").message(u"Parece que ha intentado cargar un fichero de una versión anterior. Lo siento") LOG.exception("excepcion capturada") else: self.__myUpdate() self.grid.myUpdate() return True return False
def onConfigFileSelected(self): self.configurationFile = QFileDialog.getOpenFileName(self.parent, "Choose Configuration File", self.configurationFile, "*.xml") if self.configurationFile != "": self.configurationFileChooserButton.setText(os.path.split(self.configurationFile)[1]) self.setSetting("ConfigurationFile", self.configurationFile) self.checkExecutableAndArgument()
def onBtnSelectPreseg(self): _orig_file = str(self._parameterNode.GetParameter("PresegCSVPath")) _orig_dir = os.path.dirname(_orig_file) _orig_file_name = os.path.basename(_orig_file) fname = QFileDialog.getOpenFileName(None, 'Open file', _orig_file_name , "CSV files (*.csv)") if fname: self._parameterNode.SetParameter("PresegCSVPath",fname)
def onServerExecutableSelected(self): executable = QFileDialog.getOpenFileName(self.parent, "PlusServer Executable", self.serverExecutable, "*.exe") if executable != "" and executable.find("PlusServer.exe"): self.serverExecutable = executable self.serverExecutableChooserButton.setText(executable) self.setSetting("PlusServer", executable) self.checkExecutableAndArgument()
def onConfigFileSelected(self): self.configurationFile = QFileDialog.getOpenFileName( self.parent, "Choose Configuration File", self.configurationFile, "*.xml") if self.configurationFile != "": self.configurationFileChooserButton.setText( os.path.split(self.configurationFile)[1]) self.setSetting("ConfigurationFile", self.configurationFile) self.checkExecutableAndArgument()
def FindgiFTexec(self): self.config.OptionList["giFTexecLoc"] = "" for x in self.pathArray: if os.access(x, os.X_OK): self.config.OptionList["giFTexecLoc"] = x break if len(self.config.OptionList["giFTexecLoc"]) == 0: ## Binary not found QMessageBox.warning(self.win, "giFT executable not found!", "LokiPoki couldn't find your 'giFT' server binary. \nPlease press \"ok\" to select it manually.") filename= str(QFileDialog.getOpenFileName("giFT", "giFT", self.win, "Find giFT executable")) self.config.OptionList["giFTexecLoc"] = filename
def __seleccionar_fichero(self): """ Detemina que hacer cuando se pulsa el boton de seleccion de fichero """ filtro = "%s files (*.%s);;" % ("Txt", "txt") cadenaarchivo = str(QFileDialog.getOpenFileName(QString.null, filtro, \ self, None, "importar fichero", "")) if cadenaarchivo: self.archivo = cadenaarchivo self.textLabel1.setText(cadenaarchivo) self.setNextEnabled(self.page(0), True)
def chooseWallpaper(self): prog = QFileDialog.getOpenFileName(os.path.expanduser("~"), self.trUtf8("Images (*.jpg *.png *.gif *.jpeg)")) if prog.isNull(): return item = KListViewItem(self.listWallpaper, "file", str(prog)) wallName = str(prog).split("/")[-1] self.wallpaperList[prog] = wallName item.setText(0, wallName) eheh = QPixmap(QImage(locate("data", prog)).smoothScale(150, 150, QImage.ScaleMin)) item.setPixmap(0, eheh)
def __dabrirfichero(self): """Pregunta al usuario que fichero cargar""" filterlist = "" for fmt in ["dro"]: #Candidata al fichero de listas filterlist = filterlist + "%s files (*.%s);;" % (fmt, fmt.lower()) nombrefichero = QFileDialog.getOpenFileName(QString.null, filterlist, self, None, "Dialogo abrir fichero", "") filename = str(nombrefichero) if filename: try: self.__contenido = self.__gestorsalida.cargar(filename) except AttributeError: QErrorMessage(self,"Error").message(u"Error en la carga de fichero, Probablemente versión anterior") else: self.__myUpdate()
def importDataStoresSlot(self): """ Imports the current data model with the one read from the local file system. """ targetFilePath = unicode(QFileDialog.getOpenFileName(self._lastUploadDirectory, "*.xml", self, "Import data store configuration...", "Choose a file" )) if len(targetFilePath) > 0: self._lastUploadDirectory = os.path.dirname(unicode(targetFilePath)) try: self.repositoryConfiguration.importDataStores(targetFilePath) self.repositoryConfiguration.dataStoreHandler.store() except ConfigurationError, error: self.__showErrorMessage("Cannot import data store configuration from '%s'. Reason: '%s'" \ % (targetFilePath, error.message)) else: self.updateDataStores() self.__logger.info("Successfully imported data store configurations.")
def importDatamodelSlot(self): """ Imports the current data model with the one read from the local file system. """ targetFilePath = unicode( QFileDialog.getOpenFileName(self._lastUploadDirectory, "*.xml", self, "Import data model...", "Choose a file")) if os.path.isfile(targetFilePath): self._lastUploadDirectory = os.path.dirname(targetFilePath) try: self.repositoryConfiguration.importDatamodel(targetFilePath) self.repositoryConfiguration.dataModelHandler.store() except ConfigurationError, error: self.__showErrorMessage("Cannot import data model from '%s'. Reason: '%s'" \ % (targetFilePath, error.message)) else: self.updateDataTypes() self.updateRelationTypes() self.__logger.info("Successfully imported the data model.")
def __open(self, txt, btn): filename = str(QFileDialog.getOpenFileName(None , \ "Images (*.png *.jpg *.gif)", \ self, \ "open image file", \ "Choose a file to open" )) txt.setText(filename) ok = False try: pic = QPixmap() if pic.loadFromData(open(filename, "rb").read()): ok = True if not str(self.editWidth.text()): self.editWidth.setText(str(pic.width())) if not str(self.editHeight.text()): self.editHeight.setText(str(pic.height())) self.previewImage.setPixmap(pic) btn.setEnabled(True) except: ok = False if not ok: QMessageBox.warning(self, "Warning", "Cannot open the image file!") self.previewImage.setPixmap(QPixmap()) btn.setEnabled(False)
def __open(self, txt, btn): filename = str( QFileDialog.getOpenFileName( None, "Images (*.png *.jpg *.gif)", self, "open image file", "Choose a file to open" ) ) txt.setText(filename) ok = False try: pic = QPixmap() if pic.loadFromData(open(filename, "rb").read()): ok = True if not str(self.editWidth.text()): self.editWidth.setText(str(pic.width())) if not str(self.editHeight.text()): self.editHeight.setText(str(pic.height())) self.previewImage.setPixmap(pic) btn.setEnabled(True) except: ok = False if not ok: QMessageBox.warning(self, "Warning", "Cannot open the image file!") self.previewImage.setPixmap(QPixmap()) btn.setEnabled(False)
def get_open_filename(self): file_name, _ = QFileDialog.getOpenFileName(dir='boards') return file_name
def getOpenFileName(self, caption, path, filter): """ :rtype: str """ return qt.toUnicode(QFileDialog.getOpenFileName(self, caption, path, filter))