本文整理汇总了Python中qgis.PyQt.QtWidgets.QMessageBox.question方法的典型用法代码示例。如果您正苦于以下问题:Python QMessageBox.question方法的具体用法?Python QMessageBox.question怎么用?Python QMessageBox.question使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.PyQt.QtWidgets.QMessageBox
的用法示例。
在下文中一共展示了QMessageBox.question方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mousePressEvent
# 需要导入模块: from qgis.PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QMessageBox import question [as 别名]
def mousePressEvent(self, event):
self.oldx = event.x()
self.oldy = event.y()
highlighted = self.highlight(event.x(), event.y())
if highlighted:
if self.tool == "delete":
if QMessageBox.Ok == QMessageBox.question(self, "Delete one edge", "Do you want to delete selectd edge ?", QMessageBox.Ok|QMessageBox.Cancel):
self.scene.delete_highlighted("edge")
self.scene.update("edge")
self.update()
if self.tool == "add":
if self.previous_pick:
self.scene.add_edge(self.previous_pick, highlighted)
self.previous_pick = None
self.scene.update("edge")
self.update()
else:
self.previous_pick = highlighted
else:
self.previous_pick = None
示例2: batchUpgradePostgis
# 需要导入模块: from qgis.PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QMessageBox import question [as 别名]
def batchUpgradePostgis(self, dbList):
exceptionDict = dict()
successList = []
if QMessageBox.question(self, self.tr('Question'), self.tr('This operation will upgrade PostGIS version for templates databases as well as the selected databases. Would you like to continue?'), QMessageBox.Ok|QMessageBox.Cancel) == QMessageBox.Cancel:
return successList, exceptionDict
dbsDict = self.instantiateAbstractDbs(instantiateTemplates = True)
self.closeAbstractDbs(dbsDict)
for dbName in dbsDict:
try:
if self.serverWidget.abstractDb.checkIfTemplate(dbName):
self.serverWidget.abstractDb.setDbAsTemplate(dbName = dbName, setTemplate = False)
dbsDict[dbName].upgradePostgis()
self.serverWidget.abstractDb.setDbAsTemplate(dbName = dbName, setTemplate = True)
successList.append(dbName)
else:
dbsDict[dbName].upgradePostgis()
successList.append(dbName)
except Exception as e:
exceptionDict[dbName] = ':'.join(e.args)
return successList, exceptionDict
示例3: on_dropDatabasePushButton_clicked
# 需要导入模块: from qgis.PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QMessageBox import question [as 别名]
def on_dropDatabasePushButton_clicked(self):
'''
Drops a database and updates QSettings
'''
currentItem = self.dbListWidget.currentItem()
if not currentItem:
return
if QMessageBox.question(self, self.tr('Question'), self.tr('Do you really want to drop database: ')+currentItem.text().split(' ')[0], QMessageBox.Ok|QMessageBox.Cancel) == QMessageBox.Cancel:
return
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
localDbName = self.localDb.getDatabaseName()
self.renewDb()
try:
self.serverWidget.abstractDb.dropDatabase(localDbName)
QApplication.restoreOverrideCursor()
QMessageBox.warning(self, self.tr('Success!'), self.tr('Database ')+localDbName+self.tr(' dropped successfully!'))
self.clearQSettings(localDbName)
except Exception as e:
QApplication.restoreOverrideCursor()
QMessageBox.critical(self, self.tr('Critical!'), ':'.join(e.args))
self.clearAll()
self.populateListWithDatabasesFromServer()
示例4: on_removeUserButton_clicked
# 需要导入模块: from qgis.PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QMessageBox import question [as 别名]
def on_removeUserButton_clicked(self):
selectedUsers = self.serverUserTable.selectedItems()
if not self.abstractDb:
QMessageBox.critical(self, self.tr('Critical!'), self.tr('First select a database!'))
return
if len(selectedUsers) == 0:
QMessageBox.critical(self, self.tr('Critical!'), self.tr('First select a user to remove!'))
return
selectedUserNames = [i.text(0) for i in selectedUsers]
if QMessageBox.question(self, self.tr('Question'), self.tr('Do you really want to remove users: ')+', '.join(selectedUserNames), QMessageBox.Ok|QMessageBox.Cancel) == QMessageBox.Cancel:
return
exceptionDict = dict()
successList = []
for user in selectedUserNames:
try:
self.abstractDb.reassignAndDropUser(user)
successList.append(user)
except Exception as e:
exceptionDict[user] = ':'.join(e.args)
header = self.tr('Drop user(s) operation complete!\n')
self.outputMessage(header, successList, exceptionDict)
self.populateUsers()
示例5: execute
# 需要导入模块: from qgis.PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QMessageBox import question [as 别名]
def execute(self):
"""
Called whenever the action is triggered
"""
reply = QMessageBox.question(None,
self.tr("Delete Script"),
self.tr("Are you sure you want to delete this script?"),
QMessageBox.Yes | QMessageBox.No,
QMessageBox.No)
if reply == QMessageBox.Yes:
file_path = self.itemData.description_file
if file_path is not None:
os.remove(file_path)
QgsApplication.processingRegistry().providerById("r").refreshAlgorithms()
else:
QMessageBox.warning(None,
self.tr("Delete Script"),
self.tr("Can not find corresponding script file."))
示例6: clearAll
# 需要导入模块: from qgis.PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QMessageBox import question [as 别名]
def clearAll(self):
reply = QMessageBox.question(
self, 'Message',
'Are your sure you want to delete all locations?',
QMessageBox.Yes, QMessageBox.No)
if reply == QMessageBox.Yes:
self.resultsTable.blockSignals(True)
self.removeMarkers()
self.resultsTable.setRowCount(0)
self.resultsTable.blockSignals(False)
示例7: removeTableRows
# 需要导入模块: from qgis.PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QMessageBox import question [as 别名]
def removeTableRows(self):
'''Remove selected entries from the coordinate table.'''
indices = [x.row() for x in self.resultsTable.selectionModel().selectedRows()]
if len(indices) == 0:
return
# We need to remove the rows from the bottom to the top so that the indices
# don't change.
reply = QMessageBox.question(
self, 'Message',
'Are your sure you want to delete the selected locations?',
QMessageBox.Yes, QMessageBox.No)
if reply == QMessageBox.Yes:
# Blocking the signals is necessary to prevent the signals replacing
# the marker before it is completely removed.
self.resultsTable.blockSignals(True)
for row in sorted(indices, reverse=True):
# Remove the marker from the map
item = self.resultsTable.item(row, 0).data(Qt.UserRole)
if item.marker is not None:
self.canvas.scene().removeItem(item.marker)
item.marker = None
# Then remove the location from the table
self.resultsTable.removeRow(row)
self.resultsTable.blockSignals(False)
self.resultsTable.clearSelection()
示例8: on_dropDatabasePushButton_clicked
# 需要导入模块: from qgis.PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QMessageBox import question [as 别名]
def on_dropDatabasePushButton_clicked(self):
selectedDbNameList = self.getSelectedDbList()
if len(selectedDbNameList) == 0:
QMessageBox.warning(self, self.tr('Warning'), self.tr('Please select one or more databases to drop!'))
return
if QMessageBox.question(self, self.tr('Question'), self.tr('Do you really want to drop databases: ')+', '.join(selectedDbNameList), QMessageBox.Ok|QMessageBox.Cancel) == QMessageBox.Cancel:
return
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
successList, exceptionDict = self.batchDropDbs(selectedDbNameList)
QApplication.restoreOverrideCursor()
self.setDatabases()
header = self.tr('Drop operation complete. \n')
self.outputMessage(header, successList, exceptionDict)
self.dbsCustomSelector.setInitialState(self.dbsCustomSelector.fromLs)
示例9: on_deleteCustomizationPushButton_clicked
# 需要导入模块: from qgis.PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QMessageBox import question [as 别名]
def on_deleteCustomizationPushButton_clicked(self):
#TODO: Reimplement
customizationName = self.customizationListWidget.currentItem().text()
edgvVersion = self.versionSelectionComboBox.currentText()
if QMessageBox.question(self, self.tr('Question'), self.tr('Do you really want to delete customization ')+customizationName+'?', QMessageBox.Ok|QMessageBox.Cancel) == QMessageBox.Cancel:
return
try:
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
self.genericDbManager.deleteCustomization(customizationName, edgvVersion)
QApplication.restoreOverrideCursor()
QMessageBox.warning(self, self.tr('Success!'), self.tr('Customization ') + customizationName + self.tr(' successfully deleted.'))
self.refreshProfileList()
except Exception as e:
QApplication.restoreOverrideCursor()
QMessageBox.warning(self, self.tr('Warning!'), self.tr('Error! Problem deleting customization: ') + ':'.join(e.args))
示例10: deleteSelectedSetting
# 需要导入模块: from qgis.PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QMessageBox import question [as 别名]
def deleteSelectedSetting(self):
edgvVersion = self.genericDbManager.edgvVersion
uiParameterDict = self.getParametersFromInterface()
settingTextList = ', '.join(uiParameterDict['parameterList'])
if QMessageBox.question(self, self.tr('Question'), self.tr('Do you really want to delete ')+settingTextList+'?', QMessageBox.Ok|QMessageBox.Cancel) == QMessageBox.Cancel:
return
successDict, exceptionDict = self.manageSettings(GenericManagerWidget.Delete, selectedConfig = uiParameterDict['parameterList'])
header, operation = self.getDeleteHeader()
self.outputMessage(operation, header, successDict, exceptionDict)
示例11: setupFromFile
# 需要导入模块: from qgis.PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QMessageBox import question [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
示例12: on_deletePermissionPushButton_clicked
# 需要导入模块: from qgis.PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QMessageBox import question [as 别名]
def on_deletePermissionPushButton_clicked(self):
if self.profilesListWidget.currentItem() is not None:
profileName, edgvVersion = self.profilesListWidget.currentItem().text().split(' (')
edgvVersion = edgvVersion.replace(')','')
if QMessageBox.question(self, self.tr('Question'), self.tr('Do you really want to delete profile ')+profileName+'?', QMessageBox.Ok|QMessageBox.Cancel) == QMessageBox.Cancel:
return
try:
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
self.permissionManager.deleteSetting(profileName, edgvVersion)
QApplication.restoreOverrideCursor()
QMessageBox.warning(self, self.tr('Success!'), self.tr('Permission ') + profileName + self.tr(' successfully deleted.'))
self.refreshProfileList()
except Exception as e:
QApplication.restoreOverrideCursor()
QMessageBox.warning(self, self.tr('Warning!'), self.tr('Error! Problem deleting permission: ') + ':'.join(e.args))
示例13: set_tms_scales
# 需要导入模块: from qgis.PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QMessageBox import question [as 别名]
def set_tms_scales(self):
res = QMessageBox.question(
self.iface.mainWindow(),
self.tr('QuickMapServices'),
self.tr('Set SlippyMap scales for current project? \nThe previous settings will be overwritten!'),
QMessageBox.Yes | QMessageBox.No)
if res == QMessageBox.Yes:
# set scales
QgsProject.instance().writeEntry('Scales', '/ScalesList', self.scales_list)
# activate
QgsProject.instance().writeEntry('Scales', '/useProjectScales', True)
# update in main window
# ???? no way to update: http://hub.qgis.org/issues/11917
示例14: on_delete
# 需要导入模块: from qgis.PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QMessageBox import question [as 别名]
def on_delete(self):
res = QMessageBox.question(None,
self.tr('Delete group'),
self.tr('Delete selected group?'),
QMessageBox.Yes, QMessageBox.No)
if res == QMessageBox.Yes:
group_info = self.lstGroups.currentItem().data(Qt.UserRole)
dir_path = os.path.abspath(os.path.join(group_info.file_path, os.path.pardir))
shutil.rmtree(dir_path, True)
self.feel_list()
self.ds_model.resetModel()
示例15: on_delete
# 需要导入模块: from qgis.PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QMessageBox import question [as 别名]
def on_delete(self):
res = QMessageBox.question(None,
self.tr('Delete service'),
self.tr('Delete selected service?'),
QMessageBox.Yes, QMessageBox.No)
if res == QMessageBox.Yes:
ds_info = self.lstServices.currentItem().data(Qt.UserRole)
dir_path = os.path.abspath(os.path.join(ds_info.file_path, os.path.pardir))
shutil.rmtree(dir_path, True)
self.feel_list()
self.ds_model.resetModel()