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

The following are 7 code examples of qgis.PyQt.QtWidgets.QFileDialog.getOpenFileName(). 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: multizoom.py    From qgis-latlontools-plugin with GNU General Public License v2.0 5 votes vote down vote up
def openDialog(self):
        filename = QFileDialog.getOpenFileName(
            None, "Input File", self.dirname,
            "Text, CSV (*.txt *.csv);;All files (*.*)")[0]
        if filename:
            self.dirname = os.path.dirname(filename)
            self.readFile(filename) 
Example #2
Source File: settings.py    From qgis-latlontools-plugin with GNU General Public License v2.0 5 votes vote down vote up
def qmlOpenDialog(self):
        filename = QFileDialog.getOpenFileName(
            None, "Input QML Style File",
            self.qmlLineEdit.text(), "QGIS Layer Style File (*.qml)")[0]
        if filename:
            self.qmlStyle = filename
            self.qmlLineEdit.setText(filename)
            self.markerStyleComboBox.setCurrentIndex(2) 
Example #3
Source File: setupEarthCoverage.py    From DsgTools with GNU General Public License v2.0 5 votes vote down vote up
def setupFromFile(self):
        """
        Opens a earth coverage file
        """
        if QMessageBox.question(self, self.tr('Question'), self.tr('Do you want to open an earth coverage file?'), QMessageBox.Ok|QMessageBox.Cancel) == QMessageBox.Cancel:
            return
        filename, __ = QFileDialog.getOpenFileName(self, self.tr('Open Earth Coverage Setup configuration'), '', self.tr('Earth Coverage Files (*.json)'))
        return filename 
Example #4
Source File: setupEarthCoverage.py    From DsgTools with GNU General Public License v2.0 5 votes vote down vote up
def loadJson(self, filename):
        """
        Loads a json file
        """
        filename, __ = QFileDialog.getOpenFileName(self, self.tr('Open Field Setup configuration'), self.folder, self.tr('Earth Coverage Setup File (*.dsgearthcov)'))
        if not filename:
            return
        return self.readJsonFile(filename) 
Example #5
Source File: compat2qgis.py    From quickmapservices with GNU General Public License v2.0 5 votes vote down vote up
def getOpenFileName(parent, caption, filedir, search_filter):
    result = QFileDialog.getOpenFileName(
        parent,
        caption,
        filedir,
        search_filter
    )

    if type(result) == tuple:
        return result[0]
    return result 
Example #6
Source File: do_CalculateNoiseLevels.py    From openoise-map with GNU General Public License v3.0 5 votes vote down vote up
def reload_saved_settings(self):

        saved_settings, __ = QFileDialog.getOpenFileName(None,'Open file', on_Settings.getOneSetting('directory_last') , "Settings (*.xml);;All files (*)")

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

        try:
            on_Settings.copySavedSettingsToSettings(saved_settings)
            self.reload_settings()

        except:
            QMessageBox.information(self, self.tr("opeNoise - Calculate Noise Levels"), self.tr("Sorry, but somethigs wrong in import saved settings.")) 
Example #7
Source File: plugin.py    From albion with GNU General Public License v3.0 4 votes vote down vote up
def __import_project(self):
        fil, __ = QFileDialog.getOpenFileName(
            None,
            u"Import project from file",
            QgsProject.instance().readEntry("albion", "last_dir", "")[0],
            "File formats (*.zip)",
        )
        if not fil:
            return

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

        if fil[-4:] != ".zip":
            self.__iface.messageBar().pushWarning(
                "Albion", "unsupported extension for import"
            )

        project_name = os.path.split(fil)[1][:-4]
        dir_ = tempfile.mkdtemp()
        with zipfile.ZipFile(fil, "r") as z:
            z.extractall(dir_)

        dump = find_in_dir(dir_, ".dump")
        prj = find_in_dir(dir_, ".qgs")

        self.__iface.messageBar().pushInfo(
            "Albion", "loading {} from {}".format(project_name, dump)
        )

        dbname = os.path.splitext(os.path.basename(dump))[0]

        if Project.exists(dbname):
            if (
                QMessageBox.Yes
                != QMessageBox(
                    QMessageBox.Information,
                    "Delete existing DB",
                    "Database {} exits, to you want to delete it ?".format(
                        dbname
                    ),
                    QMessageBox.Yes | QMessageBox.No,
                ).exec_()
            ):
                return
            Project.delete(dbname)

        project = Project.import_(dbname, dump)

        QgsProject.instance().read(prj)