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


Python QFileDialog.getOpenFileName方法代碼示例

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


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

示例1: getOpenFileName

# 需要導入模塊: from qgis.PyQt.QtWidgets import QFileDialog [as 別名]
# 或者: from qgis.PyQt.QtWidgets.QFileDialog import getOpenFileName [as 別名]
def getOpenFileName(parent, caption, filedir, search_filter):
    result = QFileDialog.getOpenFileName(
        parent,
        caption,
        filedir,
        search_filter
    )

    if type(result) == tuple:
        return result[0]
    return result 
開發者ID:nextgis,項目名稱:quickmapservices,代碼行數:13,代碼來源:compat2qgis.py

示例2: openDialog

# 需要導入模塊: from qgis.PyQt.QtWidgets import QFileDialog [as 別名]
# 或者: from qgis.PyQt.QtWidgets.QFileDialog import getOpenFileName [as 別名]
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) 
開發者ID:NationalSecurityAgency,項目名稱:qgis-latlontools-plugin,代碼行數:9,代碼來源:multizoom.py

示例3: qmlOpenDialog

# 需要導入模塊: from qgis.PyQt.QtWidgets import QFileDialog [as 別名]
# 或者: from qgis.PyQt.QtWidgets.QFileDialog import getOpenFileName [as 別名]
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) 
開發者ID:NationalSecurityAgency,項目名稱:qgis-latlontools-plugin,代碼行數:10,代碼來源:settings.py

示例4: setupFromFile

# 需要導入模塊: from qgis.PyQt.QtWidgets import QFileDialog [as 別名]
# 或者: from qgis.PyQt.QtWidgets.QFileDialog import getOpenFileName [as 別名]
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 
開發者ID:dsgoficial,項目名稱:DsgTools,代碼行數:10,代碼來源:setupEarthCoverage.py

示例5: loadJson

# 需要導入模塊: from qgis.PyQt.QtWidgets import QFileDialog [as 別名]
# 或者: from qgis.PyQt.QtWidgets.QFileDialog import getOpenFileName [as 別名]
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) 
開發者ID:dsgoficial,項目名稱:DsgTools,代碼行數:10,代碼來源:setupEarthCoverage.py

示例6: reload_saved_settings

# 需要導入模塊: from qgis.PyQt.QtWidgets import QFileDialog [as 別名]
# 或者: from qgis.PyQt.QtWidgets.QFileDialog import getOpenFileName [as 別名]
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.")) 
開發者ID:Arpapiemonte,項目名稱:openoise-map,代碼行數:15,代碼來源:do_CalculateNoiseLevels.py

示例7: __import_project

# 需要導入模塊: from qgis.PyQt.QtWidgets import QFileDialog [as 別名]
# 或者: from qgis.PyQt.QtWidgets.QFileDialog import getOpenFileName [as 別名]
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) 
開發者ID:Oslandia,項目名稱:albion,代碼行數:51,代碼來源:plugin.py


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