def select_title_screenshot(self, name):
     if self.select_title_screenshot_dlg is None:
         file_filter = "*.png|PNG Images\n*|All Files"
         path = self.app.dosbox.get_capture_path(name)
         dlg = QFileDialog(path, file_filter, self, 'select_title_screenshot_dlg', True)
         dlg.connect(dlg, SIGNAL('okClicked()'), self.title_screenshot_selected)
         dlg.connect(dlg, SIGNAL('cancelClicked()'), self.destroy_select_title_screenshot_dlg)
         dlg.connect(dlg, SIGNAL('closeClicked()'), self.destroy_select_title_screenshot_dlg)
         dlg.game_name = name
         dlg.show()
         self.select_title_screenshot_dlg = dlg
     else:
         # we shouldn't need this with a modal dialog
         QMessageBox.information(self, opendlg_errormsg)
Example #2
0
    def uploadIconSlot(self):
        """
        Upload icon(s) to WebDAV-server Images collection.
        """

        filePaths = list(
            QFileDialog.getOpenFileNames("Image Files (*16.png)",
                                         self._lastUploadDirectory, self,
                                         "open file dialog", "Choose files"))
        if len(filePaths) > 0:
            self._lastUploadDirectory = os.path.dirname(unicode(filePaths[0]))
            for filePath in filePaths:
                iconName = os.path.basename(unicode(filePath))[0:-6]
                iconPath = os.path.dirname(unicode(filePath))

                # Check if icon size (named) 24 is available
                iconPath24Pixel = os.path.join(iconPath, iconName + "24.png")
                if not os.path.exists(iconPath24Pixel):
                    errorMessage = "Icon '%s24.png' does not exist!" % iconName
                    self.__logger.error(errorMessage)
                else:
                    performIconImport = True
                    if self.repositoryConfiguration.hasIcon(iconName):
                        questionMessage = u"Icon '%s' already exists!\n\n Overwrite?" % iconName
                        performIconImport = self.__showQuestion(
                            "Icon Import", questionMessage)
                    if performIconImport:
                        try:
                            self.repositoryConfiguration.addIcon(
                                iconName, iconPath)
                        except ConfigurationError, error:
                            self.__logger.error(error.message)
Example #3
0
    def uploadScriptSlot(self):
        """ Upload script(s) to WebDAV-server Scripts collection. """

        filePaths = list(
            QFileDialog.getOpenFileNames(
                "DataFinder Script Files (*.py *.tar)",
                self._lastUploadDirectory, self, "open file dialog",
                "Choose files"))
        if len(filePaths) > 0:
            self._lastUploadDirectory = os.path.dirname(unicode(filePaths[0]))
            for filePath in filePaths:
                filePath = unicode(filePath)
                performScriptImport = True
                if self.repositoryConfiguration.hasScript(
                        os.path.basename(filePath)):
                    question = "Script '%s' already exists!\n\n Overwrite?" % os.path.basename(
                        filePath)
                    performScriptImport = self.__showQuestion(
                        "Script Upload", question)
                if performScriptImport:
                    try:
                        self.repositoryConfiguration.addScript("file:///" +
                                                               filePath)
                    except ConfigurationError, error:
                        errorMessage = "Cannot add script.\n Reason: '%s'" % error.message
                        self.__showErrorMessage(errorMessage)
Example #4
0
 def __guardar_como(self):
     """Abre un diálogo pidiendo el nombre de archivo y guarda en dicho archivo"""
     filtro = ""
     for fmt in SL.extensiones_fichero:
         filtro = filtro+ "%s files (*.%s);;" % (fmt, fmt.lower())
     filename = QFileDialog.getSaveFileName(QString.null, filtro, self)
     filename = str(filename)
     if filename:
         from Driza.excepciones import FicheroExisteException, FicheroTipoDesconocidoException
         import re
         extension = re.compile('.*\..*')
         if not extension.match(filename):
             filename += ".driza"
         try:
             self.__gestorproyectos.guardar(filename)
         except FicheroExisteException, fichero:
             returncode = QMessageBox.information(self, 'Atencion:', 'El fichero' + fichero.fichero + ' ya existe' , 'Sobreescribir', 'Otro nombre', 'Cancelar', 0, 1)
             if returncode == 0:
                 self.__gestorproyectos.guardar(filename, True)
                 self.__idu.establecer_original()
                 self.__myUpdate()
             elif returncode == 1:
                 self.__guardarcomo()
         except FicheroTipoDesconocidoException:
             QMessageBox.warning(self, u'Atención', u'La extensión del fichero es incorrecta.\nPruebe con otra extensión')
             self.__gestorproyectos.fichero = None
Example #5
0
 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()
Example #7
0
    def uploadIconSlot(self):
        """
        Upload icon(s) to WebDAV-server Images collection.
        """

        filePaths = list(QFileDialog.getOpenFileNames("Image Files (*16.png)",
                                                      self._lastUploadDirectory,
                                                      self,
                                                      "open file dialog",
                                                      "Choose files" ))
        if len(filePaths) > 0:
            self._lastUploadDirectory = os.path.dirname(unicode(filePaths[0]))
            for filePath in filePaths:
                iconName = os.path.basename(unicode(filePath))[0:-6]
                iconPath = os.path.dirname(unicode(filePath))

                # Check if icon size (named) 24 is available
                iconPath24Pixel = os.path.join(iconPath, iconName + "24.png")
                if not os.path.exists(iconPath24Pixel):
                    errorMessage = "Icon '%s24.png' does not exist!" % iconName
                    self.__logger.error(errorMessage)
                else:
                    performIconImport = True
                    if self.repositoryConfiguration.hasIcon(iconName):
                        questionMessage = u"Icon '%s' already exists!\n\n Overwrite?" % iconName
                        performIconImport = self.__showQuestion("Icon Import", questionMessage)
                    if performIconImport:
                        try:
                            self.repositoryConfiguration.addIcon(iconName, iconPath)
                        except ConfigurationError, error:
                            self.__logger.error(error.message)
Example #8
0
 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()
Example #10
0
 def __dexportar(self):
     """Pregunta al usuario en que fichero exportar"""
     filterlist = ""
     for fmt in ["html"]: #Candidata al fichero de listas
         filterlist = filterlist + "%s files (*.%s);;" % (fmt, fmt.lower())
     nombrefichero = QFileDialog.getSaveFileName(QString.null, filterlist, self)
     filename = str(nombrefichero)
     if filename:
         self.__exportar(filename)
 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()
Example #12
0
	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 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()
Example #14
0
 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)
Example #15
0
    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)
Example #16
0
    def open_files(self):

        lst_file_path = QFileDialog.getOpenFileNames(
            self, "Open File(s)", self.defa_dir, "All Files (*.*)"
        )

        if len(lst_file_path) > 0:
            new_dir, new_command = get_import_run_string(lst_file_path)
            # logger.info("\n new_dir=", new_dir, ">>")
            # logger.info("\n new_command =", new_command, ">>")
            self.path_file_str = new_command
            self.defa_dir = new_dir
            self.put_str_lin()
Example #17
0
    def getFileHandleFromDialog(self):
        """ Returns a file handle to the selected file. """

        fileName = unicode(
            QFileDialog.getSaveFileName("", "All Files (*)", self.wizardView,
                                        "Save file dialog",
                                        "Choose a file name"))
        fileHandle = None
        if fileName:
            try:
                fileHandle = open(fileName, "rb")
            except IOError:
                fileHandle = None
        return fileHandle
Example #18
0
    def exportDatamodelSlot(self):
        """ Exports the current data model to the local file system. """

        proposedName = "datamodel.xml"
        targetFilePath = unicode(QFileDialog.getSaveFileName(os.path.join(self._lastUploadDirectory, proposedName),
                                                              "*.xml", self, "Export data model...", "Choose a file" ))
        if len(targetFilePath) > 0:
            self._lastUploadDirectory = os.path.dirname(targetFilePath)
            try:
                self.repositoryConfiguration.exportDatamodel(targetFilePath)
            except ConfigurationError, error:
                self.__showErrorMessage("Cannot export data model to '%s'. Reason: '%s'" % (targetFilePath, error.message))
            else:
                self.__logger.info("Successfully exported the current data model to '%s'." % targetFilePath)
Example #19
0
 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()
Example #20
0
    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.")
Example #21
0
    def exportDataStoresSlot(self):
        """ Exports the current data model to the local file system. """

        proposedName = "datastores.xml"
        targetFilePath = unicode(
            QFileDialog.getSaveFileName(
                os.path.join(self._lastUploadDirectory, proposedName), "*.xml",
                self, "Export data store configuration...", "Choose a file"))
        if len(targetFilePath) > 0:
            self._lastUploadDirectory = os.path.dirname(targetFilePath)
            try:
                self.repositoryConfiguration.exportDataStores(targetFilePath)
            except ConfigurationError, error:
                self.__showErrorMessage("Cannot export data store configuration to '%s'. \nReason: '%s'" \
                                        % (targetFilePath, error.message))
            else:
                self.__logger.info(
                    "Successfully exported the current data store configurations to '%s'."
                    % targetFilePath)
Example #22
0
    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.")
Example #23
0
    def uploadScriptSlot(self):
        """ Upload script(s) to WebDAV-server Scripts collection. """

        filePaths = list(QFileDialog.getOpenFileNames("DataFinder Script Files (*.py *.tar)",
                                                      self._lastUploadDirectory,
                                                      self,
                                                      "open file dialog",
                                                      "Choose files" ))
        if len(filePaths) > 0:
            self._lastUploadDirectory = os.path.dirname(unicode(filePaths[0]))
            for filePath in filePaths:
                filePath = unicode(filePath)
                performScriptImport = True
                if self.repositoryConfiguration.hasScript(os.path.basename(filePath)):
                    question = "Script '%s' already exists!\n\n Overwrite?" % os.path.basename(filePath)
                    performScriptImport = self.__showQuestion("Script Upload", question)
                if performScriptImport:
                    try:
                        self.repositoryConfiguration.addScript("file:///" + filePath)
                    except ConfigurationError, error:
                        errorMessage = "Cannot add script.\n Reason: '%s'" % error.message
                        self.__showErrorMessage(errorMessage)
Example #24
0
 def __dguardarfichero(self):
     """Pregunta al usuario en que fichero guardar"""
     filterlist = ""
     for fmt in ["dro"]: #Candidata al fichero de listas
         filterlist = filterlist + "%s files (*.%s);;" % (fmt, fmt.lower())
     nombrefichero = QFileDialog.getSaveFileName(QString.null, filterlist, self)
     filename = str(nombrefichero)
     if filename:
         from Driza.excepciones import FicheroExisteException, \
                 FicheroTipoDesconocidoException
         try:
             self.__gestorsalida.guardar(self.__contenido, filename)
         except FicheroExisteException,fichero:
             codigoretorno = QMessageBox.information(self, 'Atencion:', 'El fichero' +\
                     fichero.fichero + ' ya existe' , 'Sobreescribir', \
                     'Otro nombre', 'Cancelar', 0, 1)
             if codigoretorno == 0:
                 self.__gestorsalida.guardar(self.__contenido, filename, True)
             elif codigoretorno == 1:
                 self.__dguardarfichero()
         except FicheroTipoDesconocidoException:
             QMessageBox.warning(self, u'Atención', \
                     u'La extensión del fichero es incorrecta.\nPruebe con otra extensión')
Example #25
0
 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)
Example #27
0
 def get_open_filename(self):
     file_name, _ = QFileDialog.getOpenFileName(dir='boards')
     return file_name
Example #28
0
 def getSaveFileName(self, caption, path, filter):
     """
     :rtype: str
     """
     return qt.toUnicode(QFileDialog.getSaveFileName(self, caption, path, filter))
Example #29
0
    def slotAddImage(self):
        dlg = QFileDialog(getenv("HOME"))
        dlg.exec_loop()
        file = dlg.selectedFile()

        if file: self._sendImage(file.ascii())
Example #30
0
 def process_save(self):
     file_name, _ = QFileDialog.getSaveFileName(dir='boards')
     with open(file_name, 'w') as f:
         f.write(save_board(self.window.board_widget.board))