本文整理汇总了Python中PyQt4.QtCore.QUrl方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.QUrl方法的具体用法?Python QtCore.QUrl怎么用?Python QtCore.QUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore
的用法示例。
在下文中一共展示了QtCore.QUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getTiles
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QUrl [as 别名]
def getTiles(self, t, i=0):
t = int(t / 600)*600
self.getTime = t
self.getIndex = i
if i == 0:
self.tileurls = []
self.tileQimages = []
for tt in self.tiletails:
tileurl = "https://tilecache.rainviewer.com/v2/radar/%d/%s" \
% (t, tt)
self.tileurls.append(tileurl)
print self.myname + " " + str(self.getIndex) + " " + self.tileurls[i]
self.tilereq = QNetworkRequest(QUrl(self.tileurls[i]))
self.tilereply = manager.get(self.tilereq)
QtCore.QObject.connect(self.tilereply, QtCore.SIGNAL(
"finished()"), self.getTilesReply)
示例2: insert
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QUrl [as 别名]
def insert(self):
# Get text from LineEdits and make use of QUrl's
# parsing (e.g. add http:// if necessary)
url = QtCore.QUrl().fromUserInput(self.urlField.text())
text = self.textField.text()
# HTML link (convert url back to parsed url string)
link = "<a href=\"{}\">{}</a>".format(url.toString(),text)
# If we need to remove the word beneath
if self.forEditing:
# Select the word
self.cursor.select(QtGui.QTextCursor.WordUnderCursor)
# Remove it
self.cursor.removeSelectedText()
# Insert this link
self.cursor.insertHtml(link)
# Close window after
self.close()
示例3: getwx
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QUrl [as 别名]
def getwx():
global wxurl
global wxreply
print "getting current and forecast:" + time.ctime()
wxurl = 'https://api.darksky.net/forecast/' + \
ApiKeys.dsapi + \
'/'
wxurl += str(Config.location.lat) + ',' + \
str(Config.location.lng)
wxurl += '?units=us&lang=' + Config.Language.lower()
wxurl += '&r=' + str(random.random())
print wxurl
r = QUrl(wxurl)
r = QNetworkRequest(r)
wxreply = manager.get(r)
wxreply.finished.connect(wxfinished)
示例4: cbUserData
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QUrl [as 别名]
def cbUserData(self, data):
self.currentUserData = data
if self.toolbar.avatarImage is None:
manager = QNetworkAccessManager()
manager.finished.connect(self.returnAvatar)
if 's3.amazonaws.com' in data['avatar_url']:
imageUrl = QUrl(data['avatar_url'])
else:
imageUrl = QUrl('http:' + data['avatar_url'])
request = QNetworkRequest(imageUrl)
request.setRawHeader('User-Agent', 'QGIS 2.x')
reply = manager.get(request)
loop = QEventLoop()
reply.finished.connect(loop.exit)
loop.exec_()
self.setUpUserData()
示例5: cbUserData
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QUrl [as 别名]
def cbUserData(self, data):
if 'error' in data:
# TODO Create image for error
self.nameLB.setText("<html><head/><body><p><span style=\" text-decoration: underline; color:red;\">error</span></p></body></html>")
self.error.emit(data['error'])
return
self.currentUserData = data
self.settings.setValue('/CartoDBPlugin/selected', self.currentUser)
manager = QNetworkAccessManager()
manager.finished.connect(self.returnAvatar)
if 's3.amazonaws.com' in data['avatar_url']:
imageUrl = QUrl(data['avatar_url'])
else:
imageUrl = QUrl('http:' + data['avatar_url'])
request = QNetworkRequest(imageUrl)
request.setRawHeader('User-Agent', 'QGIS 2.x')
reply = manager.get(request)
loop = QEventLoop()
reply.finished.connect(loop.exit)
loop.exec_()
示例6: getUserTables
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QUrl [as 别名]
def getUserTables(self, page=1, per_page=20, shared='yes', returnDict=True):
self.returnDict = returnDict
payload = {
'tag_name': '',
'q': '',
'page': page,
'type': '',
'exclude_shared': 'false',
'per_page': per_page,
'tags': '',
'shared': shared,
'locked': 'false',
'only_liked': 'false',
'order': 'name',
'types': 'table'
}
url = QUrl(self.apiUrl + "viz?api_key={}&{}".format(self.apiKey, urllib.urlencode(payload)))
request = self._getRequest(url)
reply = self.manager.get(request)
loop = QEventLoop()
reply.downloadProgress.connect(self.progressCB)
reply.error.connect(self._error)
reply.finished.connect(loop.exit)
loop.exec_()
示例7: upload
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QUrl [as 别名]
def upload(self, filePath, returnDict=True):
self.returnDict = returnDict
file = QFile(filePath)
file.open(QFile.ReadOnly)
url = QUrl(self.apiUrl + "imports/?api_key={}".format(self.apiKey))
files = {'file': file}
multipart = self._createMultipart(files=files)
request = QNetworkRequest(url)
request.setHeader(QNetworkRequest.ContentTypeHeader, 'multipart/form-data; boundary=%s' % multipart.boundary())
request.setRawHeader('User-Agent', 'QGISCartoDB 0.2.x')
reply = self.manager.post(request, multipart)
loop = QEventLoop()
reply.uploadProgress.connect(self.progressCB)
reply.error.connect(self._error)
reply.finished.connect(loop.exit)
loop.exec_()
示例8: createVizFromTable
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QUrl [as 别名]
def createVizFromTable(self, table, name, description='', returnDict=True):
self.returnDict = returnDict
payload = {
'type': 'derived',
'name': name,
'title': name,
'description': description,
'tags': ['QGISCartoDB'],
"tables": [table]
}
url = QUrl(self.apiUrl + "viz/?api_key={}".format(self.apiKey))
request = self._getRequest(url)
reply = self.manager.post(request, json.dumps(payload))
loop = QEventLoop()
reply.downloadProgress.connect(self.progressCB)
reply.error.connect(self._error)
reply.finished.connect(loop.exit)
loop.exec_()
示例9: geocode
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QUrl [as 别名]
def geocode(self, location) :
url = QtCore.QUrl("http://maps.googleapis.com/maps/api/geocode/xml")
url.addQueryItem("address", location)
url.addQueryItem("sensor", "false")
"""
url = QtCore.QUrl("http://maps.google.com/maps/geo/")
url.addQueryItem("q", location)
url.addQueryItem("output", "csv")
url.addQueryItem("sensor", "false")
"""
request = QtNetwork.QNetworkRequest(url)
reply = self.get(request)
while reply.isRunning() :
QtGui.QApplication.processEvents()
reply.deleteLater()
self.deleteLater()
return self._parseResult(reply)
示例10: mainPyQt4Simple
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QUrl [as 别名]
def mainPyQt4Simple():
# 必要なモジュールのimport
from PyQt4.QtCore import QUrl
from PyQt4.QtGui import QApplication
from PyQt4.QtWebKit import QWebView
url = 'https://github.com/tody411/PyIntroduction'
app = QApplication(sys.argv)
# QWebViewによるWebページ表示
browser = QWebView()
browser.load(QUrl(url))
browser.show()
sys.exit(app.exec_())
## PyQt4でのWebブラウザー作成(Youtube用).
示例11: mainPyQt5
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QUrl [as 别名]
def mainPyQt5():
# 必要なモジュールのimport
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QUrl
from PyQt5.QtWebEngineWidgets import QWebEngineView
url = 'https://github.com/tody411/PyIntroduction'
app = QApplication(sys.argv)
# QWebEngineViewによるWebページ表示
browser = QWebEngineView()
browser.load(QUrl(url))
browser.show()
sys.exit(app.exec_())
示例12: show_change_log
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QUrl [as 别名]
def show_change_log(self, path):
"""
Show STDM change log window if the user have never
seen it before.
:return: None
:rtype: NoneType
"""
change_log_path = '{}/html/change_log.htm'.format(path)
change_log_url = QUrl()
change_log_url.setPath(change_log_path)
change_log_html = file_text(change_log_path)
self.webView.setHtml(
change_log_html, change_log_url
)
self.exec_()
示例13: setupUi
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QUrl [as 别名]
def setupUi(self, ChangeLog):
ChangeLog.setObjectName(_fromUtf8("ChangeLog"))
ChangeLog.resize(714, 557)
self.verticalLayout = QtGui.QVBoxLayout(ChangeLog)
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.webView = QtWebKit.QWebView(ChangeLog)
self.webView.setUrl(QtCore.QUrl(_fromUtf8("about:blank")))
self.webView.setObjectName(_fromUtf8("webView"))
self.verticalLayout.addWidget(self.webView)
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
self.buttonBox = QtGui.QDialogButtonBox(ChangeLog)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
self.horizontalLayout.addWidget(self.buttonBox)
spacerItem = QtGui.QSpacerItem(600000, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.verticalLayout.addLayout(self.horizontalLayout)
self.retranslateUi(ChangeLog)
QtCore.QMetaObject.connectSlotsByName(ChangeLog)
示例14: __init__
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QUrl [as 别名]
def __init__(self, url, request_cookiejar):
super(NikeBrowser, self).__init__()
self.setWindowTitle('终结者浏览器')
# 将字典转化成QNetworkCookieJar的格式
self.cookie_jar = QtNetwork.QNetworkCookieJar()
cookies = []
# 直接通过cookie.name和cookie.value的方式迭代
for cookie in request_cookiejar:
my_cookie = QtNetwork.QNetworkCookie(QtCore.QByteArray(cookie.name), QtCore.QByteArray(cookie.value))
my_cookie.setDomain('.nike.com')
cookies.append(my_cookie)
self.cookie_jar.setAllCookies(cookies)
self.page().networkAccessManager().setCookieJar(self.cookie_jar)
# self.cookie_jar.setCookiesFromUrl(cookies, QUrl
# ('https://secure-store.nike.com/cn/checkout/html/cart.jsp?country=CN&l=cart&site=nikestore&returnURL=http://www.nike.com/cn/zh_cn/'))
self.load(QtCore.QUrl(url))
self.show()
示例15: __init__
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QUrl [as 别名]
def __init__(self, url, request_cookiejar):
super(NikeBrowser, self).__init__()
self.setWindowTitle('终结者浏览器')
# 将字典转化成QNetworkCookieJar的格式
self.cookie_jar = QNetworkCookieJar()
cookies = []
# 直接通过cookie.name和cookie.value的方式迭代
for cookie in request_cookiejar:
my_cookie = QNetworkCookie(QByteArray(cookie.name), QByteArray(cookie.value))
my_cookie.setDomain('.nike.com')
cookies.append(my_cookie)
self.cookie_jar.setAllCookies(cookies)
self.page().networkAccessManager().setCookieJar(self.cookie_jar)
# self.cookie_jar.setCookiesFromUrl(cookies, QUrl('https://secure-store.nike.com/cn/checkout/html/cart.jsp?country=CN&l=cart&site=nikestore&returnURL=http://www.nike.com/cn/zh_cn/'))
self.load(QUrl(url))
self.show()