本文整理汇总了Python中qgis.PyQt.QtCore.QUrl方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.QUrl方法的具体用法?Python QtCore.QUrl怎么用?Python QtCore.QUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.PyQt.QtCore
的用法示例。
在下文中一共展示了QtCore.QUrl方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fetchNext
# 需要导入模块: from qgis.PyQt import QtCore [as 别名]
# 或者: from qgis.PyQt.QtCore import QUrl [as 别名]
def fetchNext(self):
if len(self.queue) == 0:
return
url = self.queue.pop(0)
self.log("fetchNext: %s" % url)
request = QNetworkRequest(QUrl(url))
request.setRawHeader("User-Agent", self.userAgent)
reply = QgsNetworkAccessManager.instance().get(request)
reply.finished.connect(self.replyFinishedSlot)
self.requestingUrls.append(url)
self.replies.append(reply)
return reply
示例2: request
# 需要导入模块: from qgis.PyQt import QtCore [as 别名]
# 或者: from qgis.PyQt.QtCore import QUrl [as 别名]
def request(self, url):
fetcher = QgsNetworkContentFetcher()
fetcher.fetchContent(QUrl(url))
evloop = QEventLoop()
fetcher.finished.connect(evloop.quit)
evloop.exec_(QEventLoop.ExcludeUserInputEvents)
fetcher.finished.disconnect(evloop.quit)
return fetcher.contentAsString()
示例3: __init__
# 需要导入模块: from qgis.PyQt import QtCore [as 别名]
# 或者: from qgis.PyQt.QtCore import QUrl [as 别名]
def __init__(self):
""" Contructor """
QDialog.__init__(self)
self.setupUi(self)
self.webView.setContextMenuPolicy(Qt.NoContextMenu)
self.webView.load(QUrl("https://all4gis.github.io/QGISFMV/"))
示例4: __sync_request
# 需要导入模块: from qgis.PyQt import QtCore [as 别名]
# 或者: from qgis.PyQt.QtCore import QUrl [as 别名]
def __sync_request(self, url):
_url = QUrl(url)
_request = QNetworkRequest(_url)
self.__replies.append(_request)
QgsNetworkAccessManager.instance().sslErrors.connect(self.__supress_ssl_errors)
_reply = QgsNetworkAccessManager.instance().get(_request)
# wait
loop = QEventLoop()
_reply.finished.connect(loop.quit)
loop.exec_()
_reply.finished.disconnect(loop.quit)
QgsNetworkAccessManager.instance().sslErrors.disconnect(self.__supress_ssl_errors)
loop = None
error = _reply.error()
if error != QNetworkReply.NoError:
raise Exception(error)
result_code = _reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
result = _reply.readAll()
self.__replies.append(_reply)
_reply.deleteLater()
if result_code in [301, 302, 307]:
redirect_url = _reply.attribute(QNetworkRequest.RedirectionTargetAttribute)
return self.__sync_request(redirect_url)
else:
return result
示例5: openURL
# 需要导入模块: from qgis.PyQt import QtCore [as 别名]
# 或者: from qgis.PyQt.QtCore import QUrl [as 别名]
def openURL(self):
QDesktopServices.openUrl(QUrl("https://qms.nextgis.com/create"))
示例6: canvasPressEvent
# 需要导入模块: from qgis.PyQt import QtCore [as 别名]
# 或者: from qgis.PyQt.QtCore import QUrl [as 别名]
def canvasPressEvent(self, event):
'''Capture the coordinate when the mouse button has been released,
format it, and copy it to the clipboard.'''
pt = self.snappoint(event.originalPixelPoint())
self.removeVertexMarker()
if settings.externalMapShowLocation:
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()
button = event.button()
canvasCRS = self.canvas.mapSettings().destinationCrs()
transform = QgsCoordinateTransform(canvasCRS, epsg4326, QgsProject.instance())
pt4326 = transform.transform(pt.x(), pt.y())
lat = pt4326.y()
lon = pt4326.x()
if settings.googleEarthMapProvider(button):
f = tempfile.NamedTemporaryFile(mode='w', suffix=".kml", delete=False)
f.write('<?xml version="1.0" encoding="UTF-8"?>')
f.write('<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">')
f.write('<Document>')
f.write(' <name>QGIS Location</name>')
f.write(' <description>{:.8f}, {:.8f}</description>'.format(lon, lat))
f.write(' <Placemark>')
f.write(' <name>QGIS Location</name>')
f.write(' <Point>')
f.write(' <coordinates>{:.8f},{:.8f},0</coordinates>'.format(lon, lat))
f.write(' </Point>')
f.write(' </Placemark>')
f.write('</Document>')
f.write('</kml>')
f.close()
if platform.system() == 'Windows':
os.startfile(f.name)
else:
webbrowser.open(f.name)
self.iface.messageBar().pushMessage("", "Viewing Coordinate %f,%f in Google Earth" % (lat, lon), level=Qgis.Info, duration=3)
else:
mapprovider = settings.getMapProviderString(lat, lon, button)
url = QUrl(mapprovider).toString()
webbrowser.open(url, new=2)
self.iface.messageBar().pushMessage("", "Viewing Coordinate %f,%f in external map" % (lat, lon), level=Qgis.Info, duration=3)