当前位置: 首页>>代码示例>>Python>>正文


Python QFileDialog.getSaveFileName方法代码示例

本文整理汇总了Python中PyQt4.Qt.QFileDialog.getSaveFileName方法的典型用法代码示例。如果您正苦于以下问题:Python QFileDialog.getSaveFileName方法的具体用法?Python QFileDialog.getSaveFileName怎么用?Python QFileDialog.getSaveFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.Qt.QFileDialog的用法示例。


在下文中一共展示了QFileDialog.getSaveFileName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start_download

# 需要导入模块: from PyQt4.Qt import QFileDialog [as 别名]
# 或者: from PyQt4.Qt.QFileDialog import getSaveFileName [as 别名]
    def start_download(self, request):
        if not self.gui:
            return

        url = unicode(request.url().toString())
        cf = self.get_cookies()

        filename = get_download_filename(url, cf)
        ext = os.path.splitext(filename)[1][1:].lower()
        filename = ascii_filename(filename[:60] + '.' + ext)
        if ext not in BOOK_EXTENSIONS:
            if ext == 'acsm':
                from calibre.gui2.dialogs.confirm_delete import confirm
                if not confirm('<p>' + _('This ebook is a DRMed EPUB file.  '
                          'You will be prompted to save this file to your '
                          'computer. Once it is saved, open it with '
                          '<a href="http://www.adobe.com/products/digitaleditions/">'
                          'Adobe Digital Editions</a> (ADE).<p>ADE, in turn '
                          'will download the actual ebook, which will be a '
                          '.epub file. You can add this book to calibre '
                          'using "Add Books" and selecting the file from '
                          'the ADE library folder.'),
                          'acsm_download', self):
                    return
            home = os.path.expanduser('~')
            name = QFileDialog.getSaveFileName(self,
                _('File is not a supported ebook type. Save to disk?'),
                os.path.join(home, filename),
                '*.*')
            if name:
                name = unicode(name)
                self.gui.download_ebook(url, cf, name, name, False)
        else:
            self.gui.download_ebook(url, cf, filename, tags=self.tags)
开发者ID:089git,项目名称:calibre,代码行数:36,代码来源:web_control.py

示例2: saveFavorite

# 需要导入模块: from PyQt4.Qt import QFileDialog [as 别名]
# 或者: from PyQt4.Qt.QFileDialog import getSaveFileName [as 别名]
 def saveFavorite(self):
     """
     Writes the current favorite (selected in the combobox) to a file, any 
     where in the disk that 
     can be given to another NE1 user (i.e. as an email attachment).
     """
     
     cmd = greenmsg("Save Favorite File: ")
     env.history.message(greenmsg("Save Favorite File:"))
     current_favorite = self.favoritesComboBox.currentText()
     favfilepath = getFavoritePathFromBasename(current_favorite)
     
     formats = \
                 "Favorite (*.txt);;"\
                 "All Files (*.*)"
      
     
     fn = QFileDialog.getSaveFileName(
         self, 
         "Save Favorite As", # caption
         favfilepath, #where to save
         formats, # file format options
         QString("Favorite (*.txt)") # selectedFilter
         )
     if not fn:
         env.history.message(cmd + "Cancelled")
     
     else:
         saveFavoriteFile(str(fn), favfilepath)
     return
开发者ID:ematvey,项目名称:NanoEngineer-1,代码行数:32,代码来源:LightingScheme_PropertyManager.py

示例3: rezip_epub2

# 需要导入模块: from PyQt4.Qt import QFileDialog [as 别名]
# 或者: from PyQt4.Qt.QFileDialog import getSaveFileName [as 别名]
 def rezip_epub2(self, epub, titre_dialogue="Enregistrer l'epub détatoué sous :"):
     self.setLabelText('Reconstruction de l\'epub')
     QtGui.QApplication.processEvents()
     # choix du nom de l'epub
     epub2 = QFileDialog.getSaveFileName(None, titre_dialogue, epub, 'epub(*.epub)')
     if zipfile.is_zipfile(epub):
         try:
             zepub = zipfile.ZipFile(epub2, mode="w",
                                    compression=zipfile.ZIP_DEFLATED, allowZip64=True)
             # d'abord le mimetype non compressé.
             zepub.write(os.path.join(self.dirtemp.name, "mimetype"), arcname="mimetype",
                            compress_type=zipfile.ZIP_STORED)
             # puis les autres fichiers
             exclude_files = ['.DS_Store', 'mimetype']
             for root, _dirs, files in os.walk(self.dirtemp.name):
                 for fn in files:
                     if fn in exclude_files:
                         continue
                     absfn = os.path.join(root, fn)
                     zfn = os.path.relpath(absfn, self.dirtemp.name).replace(os.sep, '/')
                     zepub.write(absfn, zfn)
             zepub.close()
         except:
             log('Impossible de rezipper cet epub.')
     return
开发者ID:vdfebook,项目名称:PersonnaLiseur,代码行数:27,代码来源:job.py

示例4: export_bookmarks

# 需要导入模块: from PyQt4.Qt import QFileDialog [as 别名]
# 或者: from PyQt4.Qt.QFileDialog import getSaveFileName [as 别名]
    def export_bookmarks(self):
        filename = QFileDialog.getSaveFileName(self, _("Export Bookmarks"),
                '%s%suntitled.pickle' % (os.getcwdu(), os.sep),
                _("Saved Bookmarks (*.pickle)"))
        if not filename:
            return

        with open(filename, 'w') as fileobj:
            cPickle.dump(self.get_bookmarks(), fileobj)
开发者ID:089git,项目名称:calibre,代码行数:11,代码来源:bookmarkmanager.py

示例5: Save

# 需要导入模块: from PyQt4.Qt import QFileDialog [as 别名]
# 或者: from PyQt4.Qt.QFileDialog import getSaveFileName [as 别名]
 def Save(self):
     d = QFileDialog(self)
     s = d.getSaveFileName()
     
     l = len(self.mt.Images)
     
     for i in xrange(l):
         self.mt.Images[i].save(s+'.'+str(i)+'.png')
         
     f = open(s,"w")
     f.write(str(l))
     f.close()
开发者ID:Dem0n3D,项目名称:variabledirection,代码行数:14,代码来源:main.py

示例6: saveToFile

# 需要导入模块: from PyQt4.Qt import QFileDialog [as 别名]
# 或者: from PyQt4.Qt.QFileDialog import getSaveFileName [as 别名]
    def saveToFile(self):
        fdiag = QFileDialog()
        
        selectedFilter = QString()
        
        if foundPandas:
            filt = self.tr("Excel Open XML Document (*.xlsx);;Portable Network Graphics (*.png)")
        else:
            filt = self.tr("Portable Network Graphics (*.png)")

        fileName = fdiag.getSaveFileName(self, self.tr("Save Data As"),
                                        datetime.now().strftime('%Y-%m-%d-T%H%M%S-') + self.modeAscii,
                                        filt, selectedFilter)
        
        if len(fileName) == 0:
            return
        
        if 'png' in  selectedFilter:
            if fileName[-4:] == '.png':
                fileName = fileName[0:-4]
            
            px =  QPixmap.grabWidget(self.graphGrp)
            px.save(fileName + '.png', "PNG")
            return
        
        if fileName[-5:] == '.xlsx':
                fileName = fileName[0:-5]
        
        data = self.excelData.getData()
        if len(data) == 0:
            mb = QMessageBox()
            mb.setIcon(QMessageBox.Warning)
            mb.setWindowTitle(self.tr('Warning'))
            mb.setText(self.tr('No data exists. No output file has been produced.'))
            mb.exec_()
            return
        
        
        if data.ndim == 1: #Bad workaround if only one line exists
            add = []
            for idx in range(0,len(data)):
                add.append(0)
            data = np.vstack((data, np.array(add)))

        df = pandas.DataFrame(data, columns=['Frequency', self.modeTuple[0], self.modeTuple[1]])
        df.to_excel(str(fileName) + '.xlsx', index=False)
开发者ID:duke-87,项目名称:hamegLCRgui,代码行数:48,代码来源:hamegLCRgui.py

示例7: saveStrandSequence

# 需要导入模块: from PyQt4.Qt import QFileDialog [as 别名]
# 或者: from PyQt4.Qt.QFileDialog import getSaveFileName [as 别名]
    def saveStrandSequence(self):
        """
        Save the strand sequence entered in the Strand text edit in the 
        specified file. 
        """
        if not self.sequenceFileName:  
            sdir = env.prefs[workingDirectory_prefs_key]
        else:
            sdir = self.sequenceFileName
           
        fileName = QFileDialog.getSaveFileName(
                     self,              
                     "Save Strand Sequence As ...",
                     sdir,
                    "Strand Sequence File (*.txt)"
                     )
        
        if fileName:
            fileName = str(fileName)
            if fileName[-4] != '.':
                fileName += '.txt'
               
            if os.path.exists(fileName):
                
                # ...and if the "Save As" file exists...
                # ... confirm overwrite of the existing file.
                
                ret = QMessageBox.warning( 
                    self, 
                    "Save Strand Sequence...", 
                    "The file \"" + fileName + "\" already exists.\n"\
                    "Do you want to overwrite the existing file or cancel?",
                    "&Overwrite", "&Cancel", "",
                    0, # Enter == button 0
                    1 ) # Escape == button 1

                if ret == 1:
                    # The user cancelled
                    return 
                    
            # write the current set of element colors into a file    
            self._writeStrandSequenceFile(
                fileName,
                str(self.sequenceTextEdit.toPlainText()))
        return
开发者ID:elfion,项目名称:nanoengineer,代码行数:47,代码来源:DnaSequenceEditor.py

示例8: saveFavorite

# 需要导入模块: from PyQt4.Qt import QFileDialog [as 别名]
# 或者: from PyQt4.Qt.QFileDialog import getSaveFileName [as 别名]
    def saveFavorite(self):
        """
        Writes the current favorite (selected in the combobox) to a file, any
        where in the disk that
        can be given to another NE1 user (i.e. as an email attachment).
        """

        cmd = greenmsg("Save Favorite File: ")
        env.history.message(greenmsg("Save Favorite File:"))
        current_favorite = self.favoritesComboBox.currentText()
        favfilepath = getFavoritePathFromBasename(current_favorite)

        #Check to see if favfilepath exists first
        if not os.path.exists(favfilepath):
            msg = "%s does not exist" % favfilepath
            env.history.message(cmd + msg)
            return
        formats = \
                    "Favorite (*.txt);;"\
                    "All Files (*.*)"

        directory = self.currentWorkingDirectory
        saveLocation = directory + "/" + current_favorite + ".txt"

        fn = QFileDialog.getSaveFileName(
            self,
            "Save Favorite As", # caption
            saveLocation, #where to save
            formats, # file format options
            QString("Favorite (*.txt)") # selectedFilter
            )
        if not fn:
            env.history.message(cmd + "Cancelled")

        else:
            #remember this directory

            dir, fil = os.path.split(str(fn))
            self.setCurrentWorkingDirectory(dir)
            saveFavoriteFile(str(fn), favfilepath)
        return
开发者ID:foulowl,项目名称:nanoengineer,代码行数:43,代码来源:ColorScheme_PropertyManager.py

示例9: write_element_rgb_table

# 需要导入模块: from PyQt4.Qt import QFileDialog [as 别名]
# 或者: from PyQt4.Qt.QFileDialog import getSaveFileName [as 别名]
    def write_element_rgb_table(self):
        """
        Save the current set of element preferences into an external file --
        currently only r,g,b color of each element will be saved.
        """
        if not self.fileName:
            from utilities.prefs_constants import workingDirectory_prefs_key   
            sdir = env.prefs[workingDirectory_prefs_key]
        else:
            sdir = self.fileName
           
        fn = QFileDialog.getSaveFileName(
                     self,              
                     "Save Element Colors As ...",
                     sdir,
                    "Element Color File (*.txt)"
                     )
        
        if fn:
            fn = str(fn)
            if fn[-4] != '.':
                fn += '.txt'
            
            import os    
            if os.path.exists(fn): # ...and if the "Save As" file exists...
                # ... confirm overwrite of the existing file.
                ret = QMessageBox.warning( self, "Save Element Colors...",
                    "The file \"" + fn + "\" already exists.\n"
                      "Do you want to overwrite the existing file or cancel?",
                    "&Overwrite", "&Cancel", "",
                    0,      # Enter == button 0
                    1 )     # Escape == button 1

                if ret == 1: # The user cancelled
                    return 
                    
            # write the current set of element colors into a file    
            saveElementColors(fn, self.elemTable.getAllElements())
            env.history.message("Element colors saved in file: [" + fn + "]")
            #After saving a file, reset the flag        
            self.isFileSaved = True        
开发者ID:elfion,项目名称:nanoengineer,代码行数:43,代码来源:elementColors.py

示例10: _saveImage

# 需要导入模块: from PyQt4.Qt import QFileDialog [as 别名]
# 或者: from PyQt4.Qt.QFileDialog import getSaveFileName [as 别名]
 def _saveImage(self):
     filename = QFileDialog.getSaveFileName(self, "Save FITS file", self._save_dir,
                                            "FITS files(*.fits *.FITS *fts *FTS)")
     filename = str(filename)
     if not filename:
         return
     busy = BusyIndicator()
     self._imgman.showMessage("""Writing FITS image %s""" % filename, 3000)
     QApplication.flush()
     try:
         self.image.save(filename)
     except Exception as exc:
         busy = None
         traceback.print_exc()
         self._imgman.showErrorMessage("""Error writing FITS image %s: %s""" % (filename, str(sys.exc_info()[1])))
         return None
     self.renderControl().startSavingConfig(filename)
     self.setName(self.image.name)
     self._qa_save.setVisible(False)
     self._wsave.hide()
     busy = None
开发者ID:ska-sa,项目名称:tigger,代码行数:23,代码来源:Controller.py

示例11: saveToFile

# 需要导入模块: from PyQt4.Qt import QFileDialog [as 别名]
# 或者: from PyQt4.Qt.QFileDialog import getSaveFileName [as 别名]
 def saveToFile(self):
     fileName = QFileDialog.getSaveFileName(self,
             "Open Points File",
             "",
             "All Files (*);;Text Files (*.txt);;Excel (*.xlsx)", "")
     if fileName[-4:]==".txt":
         f = open(fileName, 'w')  
         f.write("            Y             X  \n") 
         for i,j in self.provisionals.iteritems():
             f.write(i +":    "+" "+ str(round(float(j.y),3))+"     "+ str(round(float(j.x),3))+"\n\n")
         f.close()
     elif fileName[-5:]==".xlsx":
         fileName=str(fileName)
         workbook = xlsxwriter.Workbook(fileName)
         worksheet = workbook.add_worksheet()
         i=0
         for nm,j in sorted(self.provisionals.iteritems()):
             worksheet.write(i,0, nm)
             worksheet.write(i,1, (round(float(j.y),3)))
             worksheet.write(i,2, (round(float(j.x),3)))
             i+=1
             
         workbook.close()
开发者ID:CraigNielsen,项目名称:LeastSquaresGui,代码行数:25,代码来源:main1.py

示例12: saveAnimation

# 需要导入模块: from PyQt4.Qt import QFileDialog [as 别名]
# 或者: from PyQt4.Qt.QFileDialog import getSaveFileName [as 别名]
 def saveAnimation(self, listOfAnimatedElements, description=""):
     """
     TODO: Doesn't work. Implement.
     
     Serializes the animation after showing the user a dialog to
     choose where to do so.
     
     :param    listOfAnimatedElements: The list of objects which compose this
                                       animation.
     :type     listOfAnimatedElements: [Animation2]
     .
     :param    fileName:               The name of the file in which this animation
                                       should be saved.
     :type     fileName:               str
     
     :param    description:            (optional) Brief description for this animation.
     :type     description:            str
     """
     filename = QFileDialog.getSaveFileName(
                                parent = None,
                                caption = "Save animation layer",
                                filter=("All Files (*.*)"));
     #print filename
     pass
开发者ID:CarlosNandreu,项目名称:THREDDSExplorer,代码行数:26,代码来源:AnimationPersistenceManager.py

示例13: __init__

# 需要导入模块: from PyQt4.Qt import QFileDialog [as 别名]
# 或者: from PyQt4.Qt.QFileDialog import getSaveFileName [as 别名]
    def __init__(self, title=_('Choose Files'),
                       filters=[],
                       add_all_files_filter=True,
                       parent=None,
                       modal=True,
                       name='',
                       mode=QFileDialog.ExistingFiles,
                       default_dir=u'~',
                       no_save_dir=False,
                       combine_file_and_saved_dir=False
                       ):
        QObject.__init__(self)
        ftext = ''
        if filters:
            for filter in filters:
                text, extensions = filter
                extensions = ['*'+(i if i.startswith('.') else '.'+i) for i in
                        extensions]
                ftext += '%s (%s);;'%(text, ' '.join(extensions))
        if add_all_files_filter or not ftext:
            ftext += 'All files (*)'
        if ftext.endswith(';;'):
            ftext = ftext[:-2]

        self.dialog_name = name if name else 'dialog_' + title
        self.selected_files = None
        self.fd = None

        if combine_file_and_saved_dir:
            bn = os.path.basename(default_dir)
            prev = dynamic.get(self.dialog_name,
                    expanduser(u'~'))
            if os.path.exists(prev):
                if os.path.isfile(prev):
                    prev = os.path.dirname(prev)
            else:
                prev = expanduser(u'~')
            initial_dir = os.path.join(prev, bn)
        elif no_save_dir:
            initial_dir = expanduser(default_dir)
        else:
            initial_dir = dynamic.get(self.dialog_name,
                    expanduser(default_dir))
        if not isinstance(initial_dir, basestring):
            initial_dir = expanduser(default_dir)
        if not initial_dir or (not os.path.exists(initial_dir) and not (
                mode == QFileDialog.AnyFile and (no_save_dir or combine_file_and_saved_dir))):
            initial_dir = select_initial_dir(initial_dir)
        self.selected_files = []
        use_native_dialog = 'CALIBRE_NO_NATIVE_FILEDIALOGS' not in os.environ
        with SanitizeLibraryPath():
            opts = QFileDialog.Option()
            if not use_native_dialog:
                opts |= QFileDialog.DontUseNativeDialog
            if mode == QFileDialog.AnyFile:
                f = unicode(QFileDialog.getSaveFileName(parent, title,
                    initial_dir, ftext, "", opts))
                if f:
                    self.selected_files.append(f)
            elif mode == QFileDialog.ExistingFile:
                f = unicode(QFileDialog.getOpenFileName(parent, title,
                    initial_dir, ftext, "", opts))
                if f and os.path.exists(f):
                    self.selected_files.append(f)
            elif mode == QFileDialog.ExistingFiles:
                fs = QFileDialog.getOpenFileNames(parent, title, initial_dir,
                        ftext, "", opts)
                for f in fs:
                    f = unicode(f)
                    if not f:
                        continue
                    if not os.path.exists(f):
                        # QFileDialog for some reason quotes spaces
                        # on linux if there is more than one space in a row
                        f = unquote(f)
                    if f and os.path.exists(f):
                        self.selected_files.append(f)
            else:
                if mode == QFileDialog.Directory:
                    opts |= QFileDialog.ShowDirsOnly
                f = unicode(QFileDialog.getExistingDirectory(parent, title, initial_dir, opts))
                if os.path.exists(f):
                    self.selected_files.append(f)
        if self.selected_files:
            self.selected_files = [unicode(q) for q in self.selected_files]
            saved_loc = self.selected_files[0]
            if os.path.isfile(saved_loc):
                saved_loc = os.path.dirname(saved_loc)
            if not no_save_dir:
                dynamic[self.dialog_name] = saved_loc
        self.accepted = bool(self.selected_files)
开发者ID:piewsook,项目名称:calibre,代码行数:93,代码来源:__init__.py

示例14: ExportAction

# 需要导入模块: from PyQt4.Qt import QFileDialog [as 别名]
# 或者: from PyQt4.Qt.QFileDialog import getSaveFileName [as 别名]
 def ExportAction(self):
     filename = QFileDialog.getSaveFileName(self, 'Messung Exportieren')
     if not filename == '':
         self.MainProgramm.Export(filename)
     return
开发者ID:mbieker,项目名称:Schaukel,代码行数:7,代码来源:MainWindow.py

示例15: SaveAction

# 需要导入模块: from PyQt4.Qt import QFileDialog [as 别名]
# 或者: from PyQt4.Qt.QFileDialog import getSaveFileName [as 别名]
 def SaveAction(self):
     #Filename zum Speichern vom Benutzer erfragen
     filename = QFileDialog.getSaveFileName(self, 'Messung Speichern')
     if not filename == '':
         self.MainProgramm.SaveFile(filename)
开发者ID:mbieker,项目名称:Schaukel,代码行数:7,代码来源:MainWindow.py


注:本文中的PyQt4.Qt.QFileDialog.getSaveFileName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。