當前位置: 首頁>>代碼示例>>Python>>正文


Python QFileDialog.getSaveFileName方法代碼示例

本文整理匯總了Python中PyQt4.QtGui.QFileDialog.getSaveFileName方法的典型用法代碼示例。如果您正苦於以下問題:Python QFileDialog.getSaveFileName方法的具體用法?Python QFileDialog.getSaveFileName怎麽用?Python QFileDialog.getSaveFileName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt4.QtGui.QFileDialog的用法示例。


在下文中一共展示了QFileDialog.getSaveFileName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: showSaveDialog

# 需要導入模塊: from PyQt4.QtGui import QFileDialog [as 別名]
# 或者: from PyQt4.QtGui.QFileDialog import getSaveFileName [as 別名]
def showSaveDialog(self, title, MyFormats):
        """
        This function is called by the menu "Export/Export Shapes" of the main toolbar.
        It creates the selection dialog for the exporter
        @return: Returns the filename of the selected file.
        """

        (beg, ende) = os.path.split(self.filename)
        (fileBaseName, fileExtension) = os.path.splitext(ende)

        default_name = os.path.join(g.config.vars.Paths['output_dir'], fileBaseName)

        selected_filter = self.MyPostProcessor.output_format[0]
        filename = getSaveFileName(self,
                                   title, default_name,
                                   MyFormats, selected_filter)

        logger.info(self.tr("File: %s selected") % filename[0])
        logger.info("<a href='%s'>%s</a>" %(filename[0],filename[0]))
        return filename 
開發者ID:cnc-club,項目名稱:dxf2gcode,代碼行數:22,代碼來源:dxf2gcode.py

示例2: saveAsImage

# 需要導入模塊: from PyQt4.QtGui import QFileDialog [as 別名]
# 或者: from PyQt4.QtGui.QFileDialog import getSaveFileName [as 別名]
def saveAsImage(self):
        """ Saves the whole page as PNG/JPG image"""
        title = self.tabWidget.currentWidget().page().mainFrame().title()
        title == validateFileName(title)
        filename = QFileDialog.getSaveFileName(self,
                                      "Select Image to Save", downloaddir + title +".jpg",
                                      "JPEG Image (*.jpg);;PNG Image (*.png)" )
        if not filename.isEmpty():
            viewportsize = self.tabWidget.currentWidget().page().viewportSize()
            contentsize = self.tabWidget.currentWidget().page().mainFrame().contentsSize()
            self.tabWidget.currentWidget().page().setViewportSize(contentsize)
            img = QPixmap(contentsize)
            painter = QPainter(img)
            self.tabWidget.currentWidget().page().mainFrame().render(painter, 0xff)# 0xff=QWebFrame.AllLayers
            painter.end()
            if img.save(filename):
                QMessageBox.information(self, "Successful !","Page has been successfully saved as\n"+filename)
            self.tabWidget.currentWidget().page().setViewportSize(viewportsize) 
開發者ID:ksharindam,項目名稱:quartz-browser,代碼行數:20,代碼來源:main.py

示例3: _save_figure

# 需要導入模塊: from PyQt4.QtGui import QFileDialog [as 別名]
# 或者: from PyQt4.QtGui.QFileDialog import getSaveFileName [as 別名]
def _save_figure(self):
        formats = "Portable Network Graphic (*.png);;Adobe Acrobat (*.pdf);;Scalable Vector Graphics (*.svg)"
        output_file = QFileDialog.getSaveFileName(self, "Save as image", "untitled.png", formats)

        output_file = str(output_file).strip()

        if len(output_file) == 0:
            return

        image_size = self._context.image_size
        if not image_size:
            fig = self._slice_view_widget
        else:
            w, h, dpi = image_size
            fig = SliceViewWidget(self._context, width=w, height=h, dpi=dpi)
            fig.set_plot_layout(self._slice_view_widget.layout_figure().current_layout())

        fig.layout_figure().savefig(output_file) 
開發者ID:Statoil,項目名稱:segyviewer,代碼行數:20,代碼來源:segyviewwidget.py

示例4: execute

# 需要導入模塊: from PyQt4.QtGui import QFileDialog [as 別名]
# 或者: from PyQt4.QtGui.QFileDialog import getSaveFileName [as 別名]
def execute(owner, polygons):
    file = QFileDialog.getSaveFileName(owner, "Save polygon-csv export to...")
    if len(file) == 0:
        return

    out_file = open(file, 'w')
    for index in range(0, len(polygons)):
        vertices = polygons[index]

        for i in range(0, len(vertices), 2):
            v = vertices[i]
            out_file.write('{};{};{};{}\n'.format(index, v[0], v[1], v[2]))

        for i in range(len(vertices)-1, 0, -2):
            v = vertices[i]
            out_file.write('{};{};{};{}\n'.format(index, v[0], v[1], v[2]))

        # last but not least: close the polygon
        v = vertices[0]
        out_file.write('{};{};{};{}\n'.format(index, v[0], v[1], v[2]))

    QMessageBox().information(owner, 'Export', 'Wrote {} polygon(s)'.format(
        len(polygons)))

    out_file.close() 
開發者ID:Oslandia,項目名稱:albion,代碼行數:27,代碼來源:export_polygon_button.py

示例5: _selectFile

# 需要導入模塊: from PyQt4.QtGui import QFileDialog [as 別名]
# 或者: from PyQt4.QtGui.QFileDialog import getSaveFileName [as 別名]
def _selectFile(self, mode='export'):
        settings = QSettings('Faunalia', 'landmark')
        lastDir = settings.value('lastZipDir', '.')

        if mode == 'export':
            fileName = QFileDialog.getSaveFileName(
                None, self.tr('Select file'), lastDir, self.tr('ZIP files (*.zip *.ZIP)'))
        else:
            fileName = QFileDialog.getOpenFileName(
                None, self.tr('Select file'), lastDir, self.tr('ZIP files (*.zip *.ZIP)'))


        if fileName == '':
            return None

        if not fileName.lower().endswith('.zip'):
            fileName += '.zip'

        settings.setValue(
            'lastZipDir', QFileInfo(fileName).absoluteDir().absolutePath())
        return fileName 
開發者ID:matsu-reki,項目名稱:GkukanMusiumdb,代碼行數:23,代碼來源:landmark_plugin.py

示例6: saveashtml

# 需要導入模塊: from PyQt4.QtGui import QFileDialog [as 別名]
# 或者: from PyQt4.QtGui.QFileDialog import getSaveFileName [as 別名]
def saveashtml(self):
        """ Saves current page as HTML , bt does not saves any content (e.g images)"""
        title = self.tabWidget.currentWidget().page().mainFrame().title()
        title = validateFileName(title)
        filename = QFileDialog.getSaveFileName(self,
                                      "Enter HTML File Name", downloaddir + title +".html",
                                      "HTML Document (*.html)" )
        if filename.isEmpty(): return
        #html = self.tabWidget.currentWidget().page().mainFrame().toHtml()
        page_URL = self.tabWidget.currentWidget().url()
        useragent = self.tabWidget.currentWidget().page().userAgentForUrl(QUrl())
        doc = self.tabWidget.currentWidget().page().mainFrame().documentElement().clone()
        #doc.setInnerXml(html)
        SaveAsHtml(networkmanager, doc, filename, page_URL, useragent) 
開發者ID:ksharindam,項目名稱:quartz-browser,代碼行數:16,代碼來源:main.py

示例7: select_output_file

# 需要導入模塊: from PyQt4.QtGui import QFileDialog [as 別名]
# 或者: from PyQt4.QtGui.QFileDialog import getSaveFileName [as 別名]
def select_output_file(self):
        """[email protected] Select file to save, and gives the right extension if the user don't put it"""
        sender = self.sender()

        fileName = QFileDialog.getSaveFileName(self.dlg, "Select output file")
        
        if not fileName:
            return
            
        # If user give right file extension, we don't add it
            
        fileName,fileExtension=os.path.splitext(fileName)
        if sender == self.dlg.selectRaster: 
            if fileExtension!='.tif':
                self.dlg.outRaster.setText(fileName+'.tif')
            else:
                self.dlg.outRaster.setText(fileName+fileExtension)
        elif sender == self.dlg.selectModel: 
            self.dlg.outModel.setText(fileName+fileExtension)            
        elif sender == self.dlg.selectMatrix: 
            if fileExtension!='.csv':
                self.dlg.outMatrix.setText(fileName+'.csv')
            else:
                self.dlg.outMatrix.setText(fileName+fileExtension)
        elif sender == self.dlg.selectOutShp:
            if fileExtension!='.shp':
                self.dlg.outShp.setText(fileName+'.shp')
            else:
                self.dlg.outShp.setText(fileName+fileExtension)
        elif sender == self.dlg.selectModelStep3:
            self.dlg.inModel.setText(fileName) 
開發者ID:lennepkade,項目名稱:HistoricalMap,代碼行數:33,代碼來源:historical_map.py

示例8: browseFile

# 需要導入模塊: from PyQt4.QtGui import QFileDialog [as 別名]
# 或者: from PyQt4.QtGui.QFileDialog import getSaveFileName [as 別名]
def browseFile(self):
        """Opens a file save as dialog to get the file name"""
        fn=QFileDialog.getSaveFileName(self,"Save file as...","","CZML flies (*.czml)")
        if (fn!=""):
            self.leFileName.setText(fn) 
開發者ID:samanbey,項目名稱:czml_generator,代碼行數:7,代碼來源:prism_map_dialog.py

示例9: select_output_file

# 需要導入模塊: from PyQt4.QtGui import QFileDialog [as 別名]
# 或者: from PyQt4.QtGui.QFileDialog import getSaveFileName [as 別名]
def select_output_file(self):
        """Selects the output file directory"""
        filename = QFileDialog.getSaveFileName(self.dlg, "Select output path directory ")
        self.dlg.lineEdit.setText(filename) 
開發者ID:stanly3690,項目名稱:HotSpotAnalysis_Plugin,代碼行數:6,代碼來源:hotspot_analysis.py

示例10: exportList

# 需要導入模塊: from PyQt4.QtGui import QFileDialog [as 別名]
# 或者: from PyQt4.QtGui.QFileDialog import getSaveFileName [as 別名]
def exportList(self):
        """Display a FileDialog and export file list"""
        toDump = list()
        for myfile in self.files:
            toDump.append({
                'path': myfile[0],
                'encoding': myfile[1],
            })
            if myfile[2] and myfile[3]:
                toDump[-1]['annotation_key'] = myfile[2]
                toDump[-1]['annotation_value'] = myfile[3]
        filePath =QFileDialog.getSaveFileName(
            self,
            u'Export File List',
            self.lastLocation,
        )

        if filePath:
            self.lastLocation = os.path.dirname(filePath)
            outputFile = codecs.open(
                filePath,
                encoding='utf8',
                mode='w',
                errors='xmlcharrefreplace',
            )
            outputFile.write(
                normalizeCarriageReturns(
                    json.dumps(toDump, sort_keys=True, indent=4)
                )
            )
            outputFile.close()
            QMessageBox.information(
                None,
                'Textable',
                'File list correctly exported',
                QMessageBox.Ok
            ) 
開發者ID:axanthos,項目名稱:orange3-textable,代碼行數:39,代碼來源:OWTextableTextFiles.py

示例11: exportFile

# 需要導入模塊: from PyQt4.QtGui import QFileDialog [as 別名]
# 或者: from PyQt4.QtGui.QFileDialog import getSaveFileName [as 別名]
def exportFile(self):
        """Display a FileDialog and export segmentation to file"""
        filePath = QFileDialog.getSaveFileName(
            self,
            u'Export segmentation to File',
            self.lastLocation,
        )
        if filePath:
            self.lastLocation = os.path.dirname(filePath)
            if self.displayAdvancedSettings:
                encoding = re.sub(r"[ ]\(.+", "", self.encoding)
            else:
                encoding = "utf8"
            outputFile = codecs.open(
                filePath,
                encoding=encoding,
                mode='w',
                errors='xmlcharrefreplace',
            )
            outputFile.write(
                #normalizeCarriageReturns(
                    self.displayedSegmentation[0].get_content()
                #)
            )
            outputFile.close()
            QMessageBox.information(
                None,
                'Textable',
                'Segmentation correctly exported',
                QMessageBox.Ok
            ) 
開發者ID:axanthos,項目名稱:orange3-textable,代碼行數:33,代碼來源:OWTextableDisplay.py

示例12: exportFile

# 需要導入模塊: from PyQt4.QtGui import QFileDialog [as 別名]
# 或者: from PyQt4.QtGui.QFileDialog import getSaveFileName [as 別名]
def exportFile(self):
        """Display a FileDialog and save table to file"""
        if getattr(self, self.sendButton.changedFlag):
            QMessageBox.warning(
                None,
                'Textable',
                'Input data and/or settings have changed.\nPlease click '
                "'Send' or check 'Send automatically' before proceeding.",
                QMessageBox.Ok
            )
            return
        filePath = QFileDialog.getSaveFileName(
            self,
            u'Export Table to File',
            self.lastLocation,
        )
        if filePath:
            self.lastLocation = os.path.dirname(filePath)
            encoding = re.sub(r"[ ]\(.+", "", self.exportEncoding)
            outputFile = codecs.open(
                filePath,
                encoding=encoding,
                mode='w',
                errors='xmlcharrefreplace',
            )
            outputFile.write(self.segmentation[0].get_content())
            outputFile.close()
            QMessageBox.information(
                None,
                'Textable',
                'Table successfully exported to file.',
                QMessageBox.Ok
            ) 
開發者ID:axanthos,項目名稱:orange3-textable,代碼行數:35,代碼來源:OWTextableConvert.py

示例13: exportList

# 需要導入模塊: from PyQt4.QtGui import QFileDialog [as 別名]
# 或者: from PyQt4.QtGui.QFileDialog import getSaveFileName [as 別名]
def exportList(self):
        """Display a FileDialog and export URL list"""
        toDump = list()
        for URL in self.URLs:
            toDump.append({
                'url': URL[0],
                'encoding': URL[1],
            })
            if URL[2] and URL[3]:
                toDump[-1]['annotation_key'] = URL[2]
                toDump[-1]['annotation_value'] = URL[3]
        filePath = QFileDialog.getSaveFileName(
            self,
            u'Export URL List',
            self.lastLocation,
        )

        if filePath:
            self.lastLocation = os.path.dirname(filePath)
            outputFile = codecs.open(
                filePath,
                encoding='utf8',
                mode='w',
                errors='xmlcharrefreplace',
            )
            outputFile.write(
                normalizeCarriageReturns(
                    json.dumps(toDump, sort_keys=True, indent=4)
                )
            )
            outputFile.close()
            QMessageBox.information(
                None,
                'Textable',
                'URL list correctly exported',
                QMessageBox.Ok
            ) 
開發者ID:axanthos,項目名稱:orange3-textable,代碼行數:39,代碼來源:OWTextableURLs.py

示例14: exportList

# 需要導入模塊: from PyQt4.QtGui import QFileDialog [as 別名]
# 或者: from PyQt4.QtGui.QFileDialog import getSaveFileName [as 別名]
def exportList(self):
        """Display a FileDialog and export substitution list"""
        toDump = list()
        for substitution in self.substitutions:
            toDump.append({
                'regex': substitution[0],
                'replacement_string': substitution[1],
            })
            if substitution[2]:
                toDump[-1]['ignore_case'] = substitution[2]
            if substitution[3]:
                toDump[-1]['unicode_dependent'] = substitution[3]
            if substitution[4]:
                toDump[-1]['multiline'] = substitution[4]
            if substitution[5]:
                toDump[-1]['dot_all'] = substitution[5]
        filePath = QFileDialog.getSaveFileName(
            self,
            u'Export Substitution List',
            self.lastLocation,
        )
        if filePath:
            self.lastLocation = os.path.dirname(filePath)
            outputFile = codecs.open(
                filePath,
                encoding='utf8',
                mode='w',
                errors='xmlcharrefreplace',
            )
            outputFile.write(
                normalizeCarriageReturns(
                    json.dumps(toDump, sort_keys=True, indent=4)
                )
            )
            outputFile.close()
            QMessageBox.information(
                None,
                'Textable',
                'Substitution list correctly exported',
                QMessageBox.Ok
            ) 
開發者ID:axanthos,項目名稱:orange3-textable,代碼行數:43,代碼來源:OWTextableRecode.py

示例15: file_select_export_gml

# 需要導入模塊: from PyQt4.QtGui import QFileDialog [as 別名]
# 或者: from PyQt4.QtGui.QFileDialog import getSaveFileName [as 別名]
def file_select_export_gml(self):
        if QSettings().value('SEC4QGIS/last_folder_export') is None:
            last_folder_export = ""
        else:
            last_folder_export = QSettings().value('SEC4QGIS/last_folder_export')
        file_name = QFileDialog.getSaveFileName(self, _translate("export_gml", "Ouput GML file:"), last_folder_export, "*.gml")
        if len(file_name)>0:
            if file_name[-4:].upper() != ".GML":
                file_name = file_name+".gml"
        self.lineEdit_ouput_file.setText(file_name)
        if len(file_name)>0:
            last_folder_export = os.path.split(file_name)[0]
            QSettings().setValue('SEC4QGIS/last_folder_export', last_folder_export)
###########################################################################################################################
########################################################################################################################### 
開發者ID:yeahmike,項目名稱:sec4qgis,代碼行數:17,代碼來源:export_gml_dialog.py


注:本文中的PyQt4.QtGui.QFileDialog.getSaveFileName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。