本文整理匯總了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)