Python qgis.PyQt.QtWidgets.QFileDialog.getSaveFileName() Examples

The following are 13 code examples of qgis.PyQt.QtWidgets.QFileDialog.getSaveFileName(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module qgis.PyQt.QtWidgets.QFileDialog , or try the search function .
Example #1
Source File: plugin.py    From albion with GNU General Public License v3.0 6 votes vote down vote up
def __export_volume(self):
        assert(self.project)

        fil, __ = QFileDialog.getSaveFileName(
            None,
            u"Export volume for current graph",
            QgsProject.instance().readEntry("albion", "last_dir", "")[0],
            "File formats (*.dxf *.obj)",
        )
        if not fil:
            return

        QgsProject.instance().writeEntry("albion", "last_dir", os.path.dirname(fil))

        if fil[-4:] == ".obj":
            self.project.export_obj(self.__current_graph.currentText(), fil)
        elif fil[-4:] == ".dxf":
            self.project.export_dxf(self.__current_graph.currentText(), fil)
        else:
            self.__iface.messageBar().pushWarning(
                "Albion", "unsupported extension for volume export"
            ) 
Example #2
Source File: plugin.py    From albion with GNU General Public License v3.0 6 votes vote down vote up
def __export_sections(self):
        assert(self.project)

        fil, __ = QFileDialog.getSaveFileName(
            None,
            u"Export named sections for current graph",
            QgsProject.instance().readEntry("albion", "last_dir", "")[0],
            "File formats (*.dxf *.obj)",
        )
        if not fil:
            return

        QgsProject.instance().writeEntry("albion", "last_dir", os.path.dirname(fil))

        if fil[-4:] == ".obj":
            self.project.export_sections_obj(self.__current_graph.currentText(), fil)
        elif fil[-4:] == ".dxf":
            self.project.export_sections_dxf(self.__current_graph.currentText(), fil)
        else:
            self.__iface.messageBar().pushWarning(
                "Albion", "unsupported extension for section export"
            ) 
Example #3
Source File: plugin.py    From albion with GNU General Public License v3.0 6 votes vote down vote up
def __export_holes(self):
        assert(self.project)

        fil, __ = QFileDialog.getSaveFileName(
            None,
            u"Export holes",
            QgsProject.instance().readEntry("albion", "last_dir", "")[0],
            "File formats (*.dxf *.vtk)",
        )
        if not fil:
            return

        QgsProject.instance().writeEntry("albion", "last_dir", os.path.dirname(fil))

        if fil[-4:] == ".vtk":
            self.project.export_holes_vtk(fil)
        elif fil[-4:] == ".dxf":
            self.project.export_holes_dxf(fil)
        else:
            self.__iface.messageBar().pushWarning("Albion", "unsupported extension for hole export") 
Example #4
Source File: mainPlugin.py    From PyRAT with Mozilla Public License 2.0 6 votes vote down vote up
def pyratToLayer(layerid=None):
        """Exports a PyRAT-layer into QGIS"""
        if type(layerid) is str:
            pyrat.data.activateLayer(layerid)
        annotation = pyrat.data.getAnnotation()
        if 'info' in annotation:
            filename = path.join(pyrat.data.tmpdir, annotation['info'] +
                                 ".rat")
        else:
            filename = path.join(pyrat.data.tmpdir, "PyRAT.rat")

        filename, s = QFileDialog.getSaveFileName(
                iface.mainWindow(),
                "Save the PyRAT-Layer",
                filename,
                "RAT-File (*.rat)")

        if not s or filename == "":
            return

        pyrat.save.rat((filename, "rat"), geo_envi_hdr=True)
        iface.addRasterLayer(filename, path.basename(filename).split(".")[0]) 
Example #5
Source File: multizoom.py    From qgis-latlontools-plugin with GNU General Public License v2.0 5 votes vote down vote up
def saveDialog(self):
        filename = QFileDialog.getSaveFileName(None, "Save File", self.dirname, "Text CSV (*.csv)")[0]
        if filename:
            self.dirname = os.path.dirname(filename)
            self.saveFile(filename) 
Example #6
Source File: mapillary_api.py    From go2mapillary with GNU General Public License v3.0 5 votes vote down vote up
def download(self,key):
        res = requests.get(DOWNLOAD_ENDPOINT % key, proxies=getProxiesConf())
        if res.status_code == 200:
            fileName = QFileDialog.getSaveFileName(None,'Save mapillary Image',key+'.jpg',"JPG (*.jpg)")
            if fileName:
                with open(fileName[0], 'wb') as f:
                    f.write(res.content) 
Example #7
Source File: plugin.py    From albion with GNU General Public License v3.0 5 votes vote down vote up
def __export_layer(self):
        assert(self.project)

        table = None
        for l in self.__iface.layerTreeView().selectedLayers():
            uri = QgsDataSourceUri(l.dataProvider().dataSourceUri())
            table = uri.table()
            if table.endswith('_section'):
                table = table[:-8]
                break

        if table is None:
            self.__iface.messageBar().pushWarning("Albion", "you must select a layer")
            return

        fil, __ = QFileDialog.getSaveFileName(
            None,
            u"Export layer",
            QgsProject.instance().readEntry("albion", "last_dir", "")[0],
            "File formats (*.dxf *.vtk)",
        )
        if not fil:
            return

        QgsProject.instance().writeEntry("albion", "last_dir", os.path.dirname(fil))


        if fil.endswith('.vtk'):
            self.project.export_layer_vtk(table, fil)
        elif fil.endswith('.dxf'):
            self.project.export_layer_dxf(table, fil)
        else:
            self.__iface.messageBar().pushWarning("Albion", "unsupported extension for hole export") 
Example #8
Source File: plugin.py    From albion with GNU General Public License v3.0 5 votes vote down vote up
def __export_project(self):
        if self.project is None:
            return

        fil, __ = QFileDialog.getSaveFileName(
            None,
            u"Export project",
            QgsProject.instance().readEntry("albion", "last_dir", "")[0],
            "Data files(*.zip)",
        )
        if not fil:
            return

        QgsProject.instance().writeEntry("albion", "last_dir", os.path.dirname(fil)),

        if os.path.exists(fil):
            os.remove(fil)

        with zipfile.ZipFile(fil, "w") as project:
            dump = tempfile.mkstemp()[1]
            self.project.export(dump)
            project.write(dump, self.project.name + ".dump")
            project.write(
                QgsProject.instance().fileName(),
                os.path.split(QgsProject.instance().fileName())[1],
            ) 
Example #9
Source File: inventoryTools.py    From DsgTools with GNU General Public License v2.0 5 votes vote down vote up
def on_outputFileButton_clicked(self):
        '''
        Inventory output file selection
        '''
        if self.onlyGeoCheckBox.isChecked():
            fileName, __ = QFileDialog.getSaveFileName(parent=self, caption=self.tr('Save Output File'), filter='Shapefile (*.shp)')
        else:
            fileName, __ = QFileDialog.getSaveFileName(parent=self, caption=self.tr('Save Output File'), filter='CSV (*.csv)')
        self.outputFileEdit.setText(fileName) 
Example #10
Source File: do_CalculateNoiseLevels.py    From openoise-map with GNU General Public License v3.0 5 votes vote down vote up
def outFile_rays(self):

        self.rays_layer_lineEdit.clear()
        shapefileName, __ = QFileDialog.getSaveFileName(None,'Open file', on_Settings.getOneSetting('directory_last') , "Shapefile (*.shp);;All files (*)")

        if shapefileName is None or shapefileName == "":
            return

        if str.find(shapefileName,".shp") == -1 and str.find(shapefileName,".SHP") == -1:
            self.rays_layer_lineEdit.setText( shapefileName + ".shp")
        else:
            self.rays_layer_lineEdit.setText( shapefileName)

        on_Settings.setOneSetting('directory_last',os.path.dirname(self.rays_layer_lineEdit.text())) 
Example #11
Source File: do_CalculateNoiseLevels.py    From openoise-map with GNU General Public License v3.0 5 votes vote down vote up
def outFile_diff_rays(self):

        self.diff_rays_layer_lineEdit.clear()
        shapefileName, __ = QFileDialog.getSaveFileName(None,'Open file', on_Settings.getOneSetting('directory_last')  , "Shapefile (*.shp);;All files (*)")

        if shapefileName is None or shapefileName == "":
            return

        if str.find(shapefileName,".shp") == -1 and str.find(shapefileName,".SHP") == -1:
            self.diff_rays_layer_lineEdit.setText( shapefileName + ".shp")
        else:
            self.diff_rays_layer_lineEdit.setText( shapefileName)

        on_Settings.setOneSetting('directory_last',os.path.dirname(self.diff_rays_layer_lineEdit.text())) 
Example #12
Source File: do_CalculateNoiseLevels.py    From openoise-map with GNU General Public License v3.0 5 votes vote down vote up
def outFile_save_settings(self):

        self.save_settings_lineEdit.clear()
        save_settings_path, __ = QFileDialog.getSaveFileName(None,'Open file', on_Settings.getOneSetting('directory_last') , "Settings (*.xml);;All files (*)")

        if save_settings_path is None or save_settings_path == "":
            return

        if str.find(save_settings_path,".xml") == -1 and str.find(save_settings_path,".XML") == -1:
            self.save_settings_lineEdit.setText( save_settings_path + ".xml")
        else:
            self.save_settings_lineEdit.setText( save_settings_path )


        on_Settings.setOneSetting('directory_last',os.path.dirname(self.save_settings_lineEdit.text())) 
Example #13
Source File: do_CreateReceiverPoints.py    From openoise-map with GNU General Public License v3.0 5 votes vote down vote up
def outFile(self):
        self.receiver_layer_lineEdit.clear()

        self.shapefileName = QFileDialog.getSaveFileName(None,'Open file', on_Settings.getOneSetting('directory_last') , "Shapefile (*.shp);;All files (*)")

        if self.shapefileName is None or self.shapefileName == "":
            return
            
        if str.find(self.shapefileName[0],".shp") == -1 and str.find(self.shapefileName[0],".SHP") == -1:
            self.receiver_layer_lineEdit.setText( self.shapefileName[0] + ".shp")
        else:
            self.receiver_layer_lineEdit.setText( self.shapefileName[0])
       
        on_Settings.setOneSetting('directory_last',os.path.dirname(self.receiver_layer_lineEdit.text()))