当前位置: 首页>>代码示例>>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;未经允许,请勿转载。