本文整理汇总了Python中qgis.PyQt.QtWidgets.QApplication.setOverrideCursor方法的典型用法代码示例。如果您正苦于以下问题:Python QApplication.setOverrideCursor方法的具体用法?Python QApplication.setOverrideCursor怎么用?Python QApplication.setOverrideCursor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.PyQt.QtWidgets.QApplication
的用法示例。
在下文中一共展示了QApplication.setOverrideCursor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: canvasReleaseEvent
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import setOverrideCursor [as 别名]
def canvasReleaseEvent(self, e):
point = self.plugin.transform(
self.iface.mapCanvas().getCoordinateTransform().toMapCoordinates(e.x(), e.y())
)
QApplication.setOverrideCursor(Qt.WaitCursor)
fs = self.plugin.highlight(
where=u"st_contains(wkb_geometry,st_geomfromtext('POINT(%.3lf %.3lf)'::text,%d))" % (
point.x(), point.y(), self.plugin.getepsg()
)
)
if len(fs) == 0:
QApplication.restoreOverrideCursor()
QMessageBox.information(None, u"Fehler", u"Kein Flurstück gefunden.")
return
try:
s = QSettings("norBIT", "EDBSgen/PRO")
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("localhost", int(s.value("norGISPort", "6102"))))
sock.send("NORGIS_MAIN#EDBS#ALBKEY#{}#".format(fs[0]['flsnr']).encode("utf-8"))
sock.close()
if win32:
window = win32gui.FindWindow(None, s.value("albWin", "norGIS"))
win32gui.SetForegroundWindow(window)
except socket.error:
QMessageBox.information(None, u"Fehler", u"Verbindung zu norGIS schlug fehl.")
QApplication.restoreOverrideCursor()
示例2: editColumn
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import setOverrideCursor [as 别名]
def editColumn(self):
""" open dialog to change column info and alter table appropriately """
index = self.currentColumn()
if index == -1:
return
m = self.viewFields.model()
# get column in table
# (there can be missing number if someone deleted a column)
fld = m.getObject(index)
dlg = DlgFieldProperties(self, fld, self.table)
if not dlg.exec_():
return
new_fld = dlg.getField(True)
QApplication.setOverrideCursor(Qt.WaitCursor)
self.aboutToChangeTable.emit()
try:
fld.update(new_fld.name, new_fld.type2String(), new_fld.notNull, new_fld.default2String())
self.populateViews()
except BaseError as e:
DlgDbError.showError(e, self)
return
finally:
QApplication.restoreOverrideCursor()
示例3: setData
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import setOverrideCursor [as 别名]
def setData(self, index, value, role):
if role != Qt.EditRole or index.column() != 0:
return False
item = index.internalPointer()
new_value = unicode(value)
if isinstance(item, SchemaItem) or isinstance(item, TableItem):
obj = item.getItemData()
# rename schema or table or view
if new_value == obj.name:
return False
QApplication.setOverrideCursor(Qt.WaitCursor)
try:
obj.rename(new_value)
self._onDataChanged(index)
except BaseError as e:
DlgDbError.showError(e, self.treeView)
return False
finally:
QApplication.restoreOverrideCursor()
return True
return False
示例4: runAction
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import setOverrideCursor [as 别名]
def runAction(self, action):
action = unicode(action)
if action.startswith("vacuumanalyze/"):
if action == "vacuumanalyze/run":
self.runVacuumAnalyze()
return True
elif action.startswith("rule/"):
parts = action.split('/')
rule_name = parts[1]
rule_action = parts[2]
msg = u"Do you want to %s rule %s?" % (rule_action, rule_name)
QApplication.restoreOverrideCursor()
try:
if QMessageBox.question(None, self.tr("Table rule"), msg,
QMessageBox.Yes | QMessageBox.No) == QMessageBox.No:
return False
finally:
QApplication.setOverrideCursor(Qt.WaitCursor)
if rule_action == "delete":
self.aboutToChange.emit()
self.database().connector.deleteTableRule(rule_name, (self.schemaName(), self.name))
self.refreshRules()
return True
return Table.runAction(self, action)
示例5: refresh_databases
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import setOverrideCursor [as 别名]
def refresh_databases(self):
QApplication.setOverrideCursor(Qt.WaitCursor)
if self.clouddb:
db_list = self.api.read_databases()
if self.show_api_error(db_list):
QApplication.restoreOverrideCursor()
return
self.db_connections = DbConnections()
for db in db_list:
self.db_connections.add_from_json(db)
self.ui.tabDatabases.clear()
self.ui.btnDbDelete.setEnabled(False)
self.ui.cbUploadDatabase.clear()
self.ui.cbUploadDatabase.setEditable(True)
self.ui.cbUploadDatabase.lineEdit().setReadOnly(True)
if self.db_connections.count() == 0:
self.ui.cbUploadDatabase.setEditText(self.tr("No databases"))
else:
for name, db in list(self.db_connections.iteritems()):
it = QListWidgetItem(name)
it.setToolTip(db.description())
self.ui.tabDatabases.addItem(it)
self.ui.cbUploadDatabase.addItem(name)
if self.ui.cbUploadDatabase.count() > 1:
# Display the "Select database" text if more than one db is available
self.ui.cbUploadDatabase.setCurrentIndex(-1)
self.ui.cbUploadDatabase.setEditText(self.tr("Select database"))
self.db_connections.refresh(self.user)
self.db_size(self.db_connections)
QApplication.restoreOverrideCursor()
示例6: deleteConstraint
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import setOverrideCursor [as 别名]
def deleteConstraint(self):
""" delete a constraint """
index = self.currentConstraint()
if index == -1:
return
m = self.viewConstraints.model()
constr = m.getObject(index)
res = QMessageBox.question(self, self.tr("Are you sure"),
self.tr("really delete constraint '%s'?") % constr.name,
QMessageBox.Yes | QMessageBox.No)
if res != QMessageBox.Yes:
return
QApplication.setOverrideCursor(Qt.WaitCursor)
self.aboutToChangeTable.emit()
try:
constr.delete()
self.populateViews()
except BaseError as e:
DlgDbError.showError(e, self)
return
finally:
QApplication.restoreOverrideCursor()
示例7: zip_db
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import setOverrideCursor [as 别名]
def zip_db(self):
force_another_db = False
dbpath=None
if self.db:
use_current_db = utils.Askuser("YesNo",'Vill du göra backup av %s?'%self.db,'Which database?')
if use_current_db.result == 1:
dbpath = self.db
force_another_db = False
elif use_current_db.result == 0:
force_another_db = True
elif use_current_db.result == '':
return
if not self.db or force_another_db:
dbpath = QFileDialog.getOpenFileName(None, 'Ange db som du vill skapa backup utav','',"Spatialite (*.sqlite)")[0]
if dbpath:
QApplication.setOverrideCursor(Qt.WaitCursor)
connection = utils.dbconnection(dbpath)
connection.connect2db()
connection.conn.cursor().execute("begin immediate")
file_path = os.path.realpath(dbpath)
dir_path = os.path.dirname(file_path)
current_dir = dir_path.split(os.sep)[-1]
bkupname = dbpath + datetime.datetime.now().strftime('%Y%m%dT%H%M') + '.zip'
zf = zipfile.ZipFile(bkupname, mode='w')
zf.write(dbpath,os.path.basename(dbpath), compress_type=compression) #compression will depend on if zlib is found or not
zf.close()
connection.conn.rollback()
connection.closedb()
self.iface.messageBar().pushMessage("Information","Database backup was written to " + bkupname, 1,duration=15)
QApplication.restoreOverrideCursor()
示例8: createGeomColumn
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import setOverrideCursor [as 别名]
def createGeomColumn(self):
""" first check whether everything's fine """
if self.editName.text() == "":
QMessageBox.critical(self, self.tr("DB Manager"), self.tr("field name must not be empty"))
return
name = self.editName.text()
geom_type = self.GEOM_TYPES[self.cboType.currentIndex()]
dim = self.spinDim.value()
try:
srid = int(self.editSrid.text())
except ValueError:
srid = -1
createSpatialIndex = False
# now create the geometry column
QApplication.setOverrideCursor(Qt.WaitCursor)
try:
self.table.addGeometryColumn(name, geom_type, srid, dim, createSpatialIndex)
except DbError as e:
DlgDbError.showError(e, self)
return
finally:
QApplication.restoreOverrideCursor()
self.accept()
示例9: runAction
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import setOverrideCursor [as 别名]
def runAction(self, action):
action = str(action)
if action.startswith("spatialindex/"):
parts = action.split('/')
spatialIndex_action = parts[1]
msg = QApplication.translate("DBManagerPlugin", "Do you want to %s spatial index for field %s?") % (
spatialIndex_action, self.geomColumn)
QApplication.restoreOverrideCursor()
try:
if QMessageBox.question(None, QApplication.translate("DBManagerPlugin", "Spatial Index"), msg,
QMessageBox.Yes | QMessageBox.No) == QMessageBox.No:
return False
finally:
QApplication.setOverrideCursor(Qt.WaitCursor)
if spatialIndex_action == "create":
self.createSpatialIndex()
return True
elif spatialIndex_action == "delete":
self.deleteSpatialIndex()
return True
if action.startswith("extent/"):
if action == "extent/get":
self.refreshTableExtent()
return True
if action == "extent/estimated/get":
self.refreshTableEstimatedExtent()
return True
return Table.runAction(self, action)
示例10: fetchAvailablePlugins
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import setOverrideCursor [as 别名]
def fetchAvailablePlugins(self, reloadMode):
""" Fetch plugins from all enabled repositories."""
""" reloadMode = true: Fully refresh data from QSettings to mRepositories """
""" reloadMode = false: Fetch unready repositories only """
QApplication.setOverrideCursor(Qt.WaitCursor)
if reloadMode:
repositories.load()
plugins.clearRepoCache()
plugins.getAllInstalled()
for key in repositories.allEnabled():
if reloadMode or repositories.all()[key]["state"] == 3: # if state = 3 (error or not fetched yet), try to fetch once again
repositories.requestFetching(key)
if repositories.fetchingInProgress():
fetchDlg = QgsPluginInstallerFetchingDialog(iface.mainWindow())
fetchDlg.exec_()
del fetchDlg
for key in repositories.all():
repositories.killConnection(key)
QApplication.restoreOverrideCursor()
# display error messages for every unavailable reposioty, unless Shift pressed nor all repositories are unavailable
keepQuiet = QgsApplication.keyboardModifiers() == Qt.KeyboardModifiers(Qt.ShiftModifier)
if repositories.allUnavailable() and repositories.allUnavailable() != repositories.allEnabled():
for key in repositories.allUnavailable():
if not keepQuiet:
QMessageBox.warning(iface.mainWindow(), self.tr("QGIS Python Plugin Installer"), self.tr("Error reading repository:") + " " + key + "\n\n" + repositories.all()[key]["error"])
if QgsApplication.keyboardModifiers() == Qt.KeyboardModifiers(Qt.ShiftModifier):
keepQuiet = True
# finally, rebuild plugins from the caches
plugins.rebuild()
示例11: updateAlgsList
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import setOverrideCursor [as 别名]
def updateAlgsList():
"""Call this method when there has been any change that
requires the list of algorithms to be created again from
algorithm providers.
"""
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
Processing.loadFromProviders()
QApplication.restoreOverrideCursor()
示例12: execute
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import setOverrideCursor [as 别名]
def execute(func):
try:
QCoreApplication.processEvents()
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
return func()
finally:
QApplication.restoreOverrideCursor()
QCoreApplication.processEvents()
示例13: createTable
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import setOverrideCursor [as 别名]
def createTable(self):
""" create table with chosen fields, optionally add a geometry column """
if not self.hasSchemas:
schema = None
else:
schema = str(self.cboSchema.currentText())
if len(schema) == 0:
QMessageBox.information(self, self.tr("DB Manager"), self.tr("select schema!"))
return
table = str(self.editName.text())
if len(table) == 0:
QMessageBox.information(self, self.tr("DB Manager"), self.tr("enter table name!"))
return
m = self.fields.model()
if m.rowCount() == 0:
QMessageBox.information(self, self.tr("DB Manager"), self.tr("add some fields!"))
return
useGeomColumn = self.chkGeomColumn.isChecked()
if useGeomColumn:
geomColumn = str(self.editGeomColumn.text())
if len(geomColumn) == 0:
QMessageBox.information(self, self.tr("DB Manager"), self.tr("set geometry column name"))
return
geomType = self.GEOM_TYPES[self.cboGeomType.currentIndex()]
geomDim = self.spinGeomDim.value()
try:
geomSrid = int(self.editGeomSrid.text())
except ValueError:
geomSrid = 0
useSpatialIndex = self.chkSpatialIndex.isChecked()
flds = m.getFields()
pk_index = self.cboPrimaryKey.currentIndex()
if pk_index >= 0:
flds[pk_index].primaryKey = True
# commit to DB
QApplication.setOverrideCursor(Qt.WaitCursor)
try:
if not useGeomColumn:
self.db.createTable(table, flds, schema)
else:
geom = geomColumn, geomType, geomSrid, geomDim, useSpatialIndex
self.db.createVectorTable(table, flds, geom, schema)
except (ConnectionError, DbError) as e:
DlgDbError.showError(e, self)
return
finally:
QApplication.restoreOverrideCursor()
QMessageBox.information(self, self.tr("Good"), self.tr("everything went fine"))
示例14: tabChanged
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import setOverrideCursor [as 别名]
def tabChanged(self, index):
QApplication.setOverrideCursor(Qt.WaitCursor)
try:
self.refreshTabs()
except BaseError as e:
DlgDbError.showError(e, self)
return
finally:
QApplication.restoreOverrideCursor()
示例15: addLessons
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import setOverrideCursor [as 别名]
def addLessons(self):
ret, __ = QFileDialog.getOpenFileName(self, "Select lessons ZIP file" , "", '*.zip')
if ret:
try:
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
installLessonsFromZipFile(ret)
self.fillTree()
finally:
QApplication.restoreOverrideCursor()