本文整理汇总了Python中qgis.core.Qgis.Warning方法的典型用法代码示例。如果您正苦于以下问题:Python Qgis.Warning方法的具体用法?Python Qgis.Warning怎么用?Python Qgis.Warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.core.Qgis
的用法示例。
在下文中一共展示了Qgis.Warning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: canvasReleaseEvent
# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Warning [as 别名]
def canvasReleaseEvent(self, event):
'''Capture the coordinate when the mouse button has been released,
format it, and copy it to the clipboard. pt is QgsPointXY'''
pt = self.snappoint(event.originalPixelPoint())
self.removeVertexMarker()
if settings.captureShowLocation:
if self.marker is None:
self.marker = QgsVertexMarker(self.canvas)
self.marker.setIconSize(18)
self.marker.setPenWidth(2)
self.marker.setIconType(QgsVertexMarker.ICON_CROSS)
self.marker.setCenter(pt)
else:
self.removeMarker()
try:
msg = self.formatCoord(pt, self.settings.delimiter)
formatString = self.coordFormatString()
if msg is not None:
clipboard = QApplication.clipboard()
clipboard.setText(msg)
self.iface.messageBar().pushMessage("", "{} coordinate {} copied to the clipboard".format(formatString, msg), level=Qgis.Info, duration=4)
except Exception as e:
self.iface.messageBar().pushMessage("", "Invalid coordinate: {}".format(e), level=Qgis.Warning, duration=4)
示例2: zoomToPressed
# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Warning [as 别名]
def zoomToPressed(self):
try:
text = self.coordTxt.text().strip()
(lat, lon, srcCrs) = self.convertCoordinate(text)
pt = self.lltools.zoomTo(srcCrs, lat, lon)
if self.settings.persistentMarker:
if self.marker is None:
self.marker = QgsVertexMarker(self.canvas)
self.marker.setCenter(pt)
self.marker.setIconSize(18)
self.marker.setPenWidth(2)
self.marker.setIconType(QgsVertexMarker.ICON_CROSS)
elif self.marker is not None:
self.removeMarker()
except Exception:
# traceback.print_exc()
self.iface.messageBar().pushMessage("", "Invalid Coordinate", level=Qgis.Warning, duration=2)
return
示例3: log
# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Warning [as 别名]
def log(message, level_in=0):
"""
Writes to QGIS inbuilt logger accessible through panel.
:param message: logging message to write, error or URL.
:type message: str
:param level_in: integer representation of logging level.
:type level_in: int
"""
if level_in == 0:
level = Qgis.Info
elif level_in == 1:
level = Qgis.Warning
elif level_in == 2:
level = Qgis.Critical
else:
level = Qgis.Info
QgsMessageLog.logMessage(message, PLUGIN_NAME.strip(), level)
示例4: OpenStream
# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Warning [as 别名]
def OpenStream(self, _):
protocol = self.cmb_protocol.currentText().lower()
host = self.ln_host.text()
port = self.ln_port.text()
v = protocol + "://" + host + ":" + port
if host != "" and port != "":
qgsu.showUserAndLogMessage(QCoreApplication.translate(
"QgsFmvOpenStream", "Checking connection!"))
QApplication.setOverrideCursor(Qt.WaitCursor)
QApplication.processEvents()
# Check if connection exist
cap = cv2.VideoCapture(v)
ret, _ = cap.read()
cap.release()
if ret:
self.parent.AddFileRowToManager(v, v)
self.close()
else:
qgsu.showUserAndLogMessage(QCoreApplication.translate(
"QgsFmvOpenStream", "There is no such connection!"), level=QGis.Warning)
QApplication.restoreOverrideCursor()
示例5: packetStreamParser
# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Warning [as 别名]
def packetStreamParser(self, stdout_data):
'''Common packet process
@type stdout_data: String
@param stdout_data: Binary data
'''
for packet in StreamParser(stdout_data):
try:
if isinstance(packet, UnknownElement):
qgsu.showUserAndLogMessage(
"Error interpreting klv data, metadata cannot be read.", "the parser did not recognize KLV data", level=QGis.Warning, onlyLog=True)
continue
data = packet.MetadataList()
self.data = data
if self.metadataDlg.isVisible(): # Only add metadata to table if this QDockWidget is visible (speed plugin)
self.addMetadata(data)
try:
UpdateLayers(packet, parent=self,
mosaic=self.createingMosaic, group=self.fileName)
except Exception:
None
QApplication.processEvents()
return
except Exception as e:
qgsu.showUserAndLogMessage("", "QgsFmvPlayer packetStreamParser failed! : " + str(e), onlyLog=True)
示例6: canvasPressEvent
# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Warning [as 别名]
def canvasPressEvent(self, event):
"""Capture the coordinate when the mouse button has been released."""
pt = self.snappoint(event.originalPixelPoint())
self.removeVertexMarker()
if self.azDigitizerDialog is None:
from .azDigitizer import AzDigitizerWidget
self.azDigitizerDialog = AzDigitizerWidget(self.iface, self.iface.mainWindow())
layer = self.iface.activeLayer()
if layer is None or layer.wkbType() != QgsWkbTypes.Point:
self.azDigitizerDialog.includeStartLabel.setEnabled(False)
self.azDigitizerDialog.checkBox.setEnabled(False)
else:
self.azDigitizerDialog.includeStartLabel.setEnabled(True)
self.azDigitizerDialog.checkBox.setEnabled(True)
try:
canvasCRS = self.canvas.mapSettings().destinationCrs()
transform = QgsCoordinateTransform(canvasCRS, epsg4326, QgsProject.instance())
pt4326 = transform.transform(pt.x(), pt.y())
self.azDigitizerDialog.setPoint(pt4326)
self.azDigitizerDialog.show()
except Exception:
self.iface.messageBar().pushMessage("", tr("Clicked location is invalid"), level=Qgis.Warning, duration=4)
示例7: canvasPressEvent
# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Warning [as 别名]
def canvasPressEvent(self, event):
'''Capture the coordinate when the mouse button has been released.'''
pt = self.snappoint(event.originalPixelPoint())
self.removeVertexMarker()
layer = self.iface.activeLayer()
if layer is None:
return
if self.lineDigitizerDialog is None:
from .lineDigitizer import LineDigitizerWidget
self.lineDigitizerDialog = LineDigitizerWidget(self.iface, self.iface.mainWindow())
if layer.geometryType() == QgsWkbTypes.LineGeometry:
self.lineDigitizerDialog.closeLineCheckBox.setEnabled(True)
else:
self.lineDigitizerDialog.closeLineCheckBox.setEnabled(False)
try:
canvasCRS = self.canvas.mapSettings().destinationCrs()
transform = QgsCoordinateTransform(canvasCRS, epsg4326, QgsProject.instance())
pt4326 = transform.transform(pt.x(), pt.y())
self.lineDigitizerDialog.setPoint(pt4326)
self.lineDigitizerDialog.valuesTextEdit.clear()
self.lineDigitizerDialog.show()
except Exception:
self.iface.messageBar().pushMessage("", tr("Clicked location is invalid"), level=Qgis.Warning, duration=4)
示例8: validate
# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Warning [as 别名]
def validate(self):
"""
Verifies contents displayed on mapping table in order to infer its validity
as datasource conversion map.
:return: (bool) map validity status.
"""
# validate map
msg = self.invalidatedReason()
if msg:
# if an invalidation reason was given, warn user and nothing else.
msgBar = QgsMessageBar(self)
# if window is resized, msgBar stays, not ideal, but works for now
# maybe we should connect to some parent resizing signal or something...
msgBar.resize(QSize(self.geometry().size().width(), msgBar.geometry().height()))
msgBar.pushMessage(self.tr('Warning!'), msg, level=Qgis.Warning, duration=5)
QgsMessageLog.logMessage(msg, 'DSGTools Plugin', Qgis.Critical)
return msg == ''
示例9: on_drawShape_clicked
# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Warning [as 别名]
def on_drawShape_clicked(self):
"""
Draws the select template shape on the map canvas
"""
scaleText = self.mScaleWidget.scaleString()
scale = int(scaleText.split(':')[-1].replace('.','').replace(',',''))/1000
size = self.sizesComboBox.currentText()
shape = self.shapesComboBox.currentText()
validated = self.validateCombos(self.sizesComboBox.currentIndex(), self.shapesComboBox.currentIndex())
if validated:
crs = self.iface.mapCanvas().mapSettings().destinationCrs()
if crs.mapUnits() == 2:
self.iface.messageBar().pushMessage(self.tr('Critical!'), self.tr('This tool does not work with angular unit reference system!'), level=Qgis.Warning, duration=3)
else:
self.run(scale, size, shape)
else:
QMessageBox.warning(self.iface.mainWindow(), self.tr(u"Error!"), self.tr(u"<font color=red>Shape value not defined :</font><br><font color=blue>Define all values to activate tool!</font>"), QMessageBox.Close)
示例10: log_warning
# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Warning [as 别名]
def log_warning(cls, msg):
QgsMessageLog.logMessage(msg, tag="Raster Vision", level=Qgis.Warning)
示例11: finishedTask
# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Warning [as 别名]
def finishedTask(self, e, result=None):
""" Common finish task function """
if e is None:
if result is None:
qgsu.showUserAndLogMessage(QCoreApplication.translate(
"QgsFmvMetadata", 'Completed with no exception and no result '
'(probably manually canceled by the user)'), level=QGis.Warning)
else:
qgsu.showUserAndLogMessage(QCoreApplication.translate(
"QgsFmvMetadata", "Succesfully " + result['task'] + "!"))
else:
qgsu.showUserAndLogMessage(QCoreApplication.translate(
"QgsFmvMetadata", "Failed " + result['task'] + "!"), level=QGis.Warning)
raise e
示例12: statusChanged
# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Warning [as 别名]
def statusChanged(self, status):
'''Signal Status video change
@type status: QMediaPlayer::MediaStatus
@param status: Video status
'''
self.handleCursor(status)
if status is QMediaPlayer.LoadingMedia or status is QMediaPlayer.StalledMedia or status is QMediaPlayer.InvalidMedia:
self.videoAvailableChanged(False)
elif status == QMediaPlayer.InvalidMedia:
qgsu.showUserAndLogMessage(QCoreApplication.translate(
"QgsFmvPlayer", self.player.errorString()), level=QGis.Warning)
self.videoAvailableChanged(False)
else:
self.videoAvailableChanged(True)
示例13: showErrorMessage
# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Warning [as 别名]
def showErrorMessage(self, message):
'''Display an error message.'''
self.iface.messageBar().pushMessage("", message, level=Qgis.Warning, duration=2)
示例14: setWarning
# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Warning [as 别名]
def setWarning(msg):
iface.messageBar().pushMessage("Warning", msg,
level = Qgis.Warning,
duration = 10)
示例15: setError
# 需要导入模块: from qgis.core import Qgis [as 别名]
# 或者: from qgis.core.Qgis import Warning [as 别名]
def setError(msg, trace=None):
iface.messageBar().pushMessage("Geoserver", msg, level=Qgis.Warning, duration=10)
if trace is not None:
QgsMessageLog.logMessage("{}:{}".format(msg, trace), level=Qgis.Critical)