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


Python Qt.QFileDialog类代码示例

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


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

示例1: select_images_on_disk

 def select_images_on_disk(uim, start_path=None):
     dlg = QFileDialog()
     logmsg('Select one or more images to add.')
     image_list = dlg.getOpenFileNames(caption='Select one or more images to add.',\
                                       directory=uim.hs.db_dpath)
     image_list = [str(fpath) for fpath in image_list]
     return image_list
开发者ID:Erotemic,项目名称:hotspotter,代码行数:7,代码来源:UIManager.py

示例2: select_database

 def select_database(uim):
     dlg = QFileDialog()
     opt = QFileDialog.ShowDirsOnly
     if uim.hs.db_dpath is None:
         db_dpath = str(dlg.getExistingDirectory(caption='Open/New Database', options=opt))
     else:
         db_dpath = str(dlg.getExistingDirectory(\
                    caption='Open/New Database', options=opt, directory=uim.hs.db_dpath))
     return db_dpath
开发者ID:Erotemic,项目名称:hotspotter,代码行数:9,代码来源:UIManager.py

示例3: Save

 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,代码行数:12,代码来源:main.py

示例4: Open

 def Open(self):
     d = QFileDialog(self)
     s = d.getOpenFileName()
     
     self.mt.exit = True
     
     f = open(s,"r")
     l = int(f.readline())
     f.close()
     
     self.mt.Images = []
     
     for i in xrange(l):
         self.mt.Images.append(QImage(s+'.'+str(i)+'.png'))
开发者ID:Dem0n3D,项目名称:variabledirection,代码行数:14,代码来源:main.py

示例5: start_download

    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,代码行数:34,代码来源:web_control.py

示例6: openStrandSequenceFile

 def openStrandSequenceFile(self):
     """
     Open (read) the user specified Strand sequence file and enter the 
     sequence in the Strand sequence Text edit. Note that it ONLY reads the 
     FIRST line of the file.
     @TODO: It only reads in the first line of the file. Also, it doesn't
            handle any special cases. (Once the special cases are clearly 
            defined, that functionality will be added. 
     """
     
     if self.parentWidget.assy.filename: 
         odir = os.path.dirname(self.parentWidget.assy.filename)
     else: 
         odir = env.prefs[workingDirectory_prefs_key]
     self.sequenceFileName = \
         str(QFileDialog.getOpenFileName( 
             self,
             "Load Strand Sequence",
             odir,
             "Strand Sequnce file (*.txt);;All Files (*.*);;"))  
     lines = self.sequenceFileName
     try:
         lines = open(self.sequenceFileName, "rU").readlines()         
     except:
         print "Exception occurred to open file: ", self.sequenceFileName
         return 
     
     sequence = lines[0]
     sequence = QString(sequence) 
     sequence = sequence.toUpper()
     self._updateSequenceAndItsComplement(sequence)
     return
开发者ID:elfion,项目名称:nanoengineer,代码行数:32,代码来源:DnaSequenceEditor.py

示例7: import_bookmarks

    def import_bookmarks(self):
        filename = QFileDialog.getOpenFileName(self, _("Import Bookmarks"), '%s' % os.getcwdu(), _("Pickled Bookmarks (*.pickle)"))
        if filename == '':
            return

        imported = None
        with open(filename, 'r') as fileobj:
            imported = cPickle.load(fileobj)

        if imported != None:
            bad = False
            try:
                for bm in imported:
                    if len(bm) != 2:
                        bad = True
                        break
            except:
                pass

            if not bad:
                bookmarks = self._model.bookmarks[:]
                for bm in imported:
                    if bm not in bookmarks and bm['title'] != 'calibre_current_page_bookmark':
                        bookmarks.append(bm)
                self.set_bookmarks(bookmarks)
开发者ID:BobPyron,项目名称:calibre,代码行数:25,代码来源:bookmarkmanager.py

示例8: _open_FASTA_File

    def _open_FASTA_File(self):
        """
        Open (read) the user specified FASTA sequence file and load it into
        the sequence field.

        @TODO: It only reads in the first line of the file. Also, it doesn't
               handle any special cases. (Once the special cases are clearly
               defined, that functionality will be added.

        @attention: This is not implemented yet.
        """
        #Urmi 20080714: should not this be only fasta file, for both load and save
        if self.parentWidget.assy.filename:
            odir = os.path.dirname(self.parentWidget.assy.filename)
        else:
            odir = env.prefs[workingDirectory_prefs_key]
        self.sequenceFileName = \
            str(QFileDialog.getOpenFileName(
                self,
                "Load FASTA sequence for " + self.current_protein.name,
                odir,
                "FASTA file (*.txt);;All Files (*.*);;"))
        lines = self.sequenceFileName
        try:
            lines = open(self.sequenceFileName, "rU").readlines()
        except:
            print "Exception occurred to open file: ", self.sequenceFileName
            return

        sequence = lines[0]
        sequence = QString(sequence)
        sequence = sequence.toUpper()
        self._setSequence(sequence)
        return
开发者ID:alaindomissy,项目名称:nanoengineer,代码行数:34,代码来源:ProteinSequenceEditor.py

示例9: saveFavorite

 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,代码行数:30,代码来源:LightingScheme_PropertyManager.py

示例10: read_element_rgb_table

 def read_element_rgb_table(self):
     """
     Open file browser to select a file to read from, read the data,
     update elements color in the selector dialog and also the display models
     """
     # Determine what directory to open.
     import os
     if self.w.assy.filename: 
         odir = os.path.dirname(self.w.assy.filename)
     else: 
         from utilities.prefs_constants import workingDirectory_prefs_key
         odir = env.prefs[workingDirectory_prefs_key]
     self.fileName = str( QFileDialog.getOpenFileName(
                             self,
                             "Load Element Color",
                             odir,
                             "Elements color file (*.txt);;All Files (*.*);;"
                              ))
     if self.fileName:
         colorTable = readElementColors(self.fileName)
         
         if not colorTable:
             env.history.message(redmsg("Error in element colors file: [" + self.fileName + "]. Colors not loaded."))
         else:
             env.history.message("Element colors loaded from file: [" + self.fileName + "].")
             for row in colorTable:
                  row[1] /= 255.0; row[2] /= 255.0; row[3] /= 255.0
             self.elemTable.setElemColors(colorTable)
             self._updateModelDisplay()     
             
             elemNum =  self.elementButtonGroup.checkedId()
             self.setDisplay(elemNum)
     #After loading a file, reset the flag        
     self.isElementModified = False        
开发者ID:ematvey,项目名称:NanoEngineer-1,代码行数:34,代码来源:elementColors.py

示例11: rezip_epub2

 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,代码行数:25,代码来源:job.py

示例12: import_bookmarks

    def import_bookmarks(self):
        filename = QFileDialog.getOpenFileName(self, _("Import Bookmarks"), '%s' % os.getcwdu(), _("Pickled Bookmarks (*.pickle)"))
        if not filename:
            return

        imported = None
        with open(filename, 'r') as fileobj:
            imported = cPickle.load(fileobj)

        if imported is not None:
            bad = False
            try:
                for bm in imported:
                    if 'title' not in bm:
                        bad = True
                        break
            except:
                pass

            if not bad:
                bookmarks = self.get_bookmarks()
                for bm in imported:
                    if bm not in bookmarks:
                        bookmarks.append(bm)
                self.set_bookmarks([bm for bm in bookmarks if bm['title'] != 'calibre_current_page_bookmark'])
开发者ID:089git,项目名称:calibre,代码行数:25,代码来源:bookmarkmanager.py

示例13: selectDirectory

 def selectDirectory(self):
     directory = QFileDialog.getExistingDirectory(QFileDialog())
     if len(directory) > 0:
         directory = pathlib.Path(directory).resolve()
         if directory.exists():
             self._rddtDataExtractor.defaultPath = directory
             self.directoryBox.setText(str(directory))
             self.setUnsavedChanges(True)
开发者ID:NSchrading,项目名称:redditDataExtractor,代码行数:8,代码来源:redditDataExtractorGUI.py

示例14: saveToFile

    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,代码行数:46,代码来源:hamegLCRgui.py

示例15: export_bookmarks

    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,代码行数:9,代码来源:bookmarkmanager.py


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