本文整理汇总了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
示例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)
示例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)
示例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
示例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)
示例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."))
示例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)