本文整理汇总了Python中PyQt4.QtCore.QUrl.setPath方法的典型用法代码示例。如果您正苦于以下问题:Python QUrl.setPath方法的具体用法?Python QUrl.setPath怎么用?Python QUrl.setPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QUrl
的用法示例。
在下文中一共展示了QUrl.setPath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search
# 需要导入模块: from PyQt4.QtCore import QUrl [as 别名]
# 或者: from PyQt4.QtCore.QUrl import setPath [as 别名]
def search(self, description):
if description.help_ref:
ref = description.help_ref
else:
raise KeyError()
url = QUrl(self.baseurl).resolved(QUrl(ref))
if url.isLocalFile():
path = url.toLocalFile()
fragment = url.fragment()
if os.path.isfile(path):
return url
elif os.path.isfile("{}.html".format(path)):
url = QUrl.fromLocalFile("{}.html".format(path))
url.setFragment(fragment)
return url
elif os.path.isdir(path) and \
os.path.isfile(os.path.join(path, "index.html")):
url = QUrl.fromLocalFile(os.path.join(path, "index.html"))
url.setFragment(fragment)
return url
else:
raise KeyError()
else:
if url.scheme() in ["http", "https"]:
path = url.path()
if not (path.endswith(".html") or path.endswith("/")):
url.setPath(path + ".html")
return url
示例2: get_authorization_url
# 需要导入模块: from PyQt4.QtCore import QUrl [as 别名]
# 或者: from PyQt4.QtCore.QUrl import setPath [as 别名]
def get_authorization_url(self, scopes):
host, port = config.setting['server_host'], config.setting['server_port']
url = QUrl()
if (host in MUSICBRAINZ_SERVERS and port == 80) or port == 443:
url.setScheme("https")
else:
url.setScheme("http")
if port != 80:
url.setPort(port)
url.setHost(host)
url.setPath("/oauth2/authorize")
url.addQueryItem("response_type", "code")
url.addQueryItem("client_id", MUSICBRAINZ_OAUTH_CLIENT_ID)
url.addQueryItem("redirect_uri", "urn:ietf:wg:oauth:2.0:oob")
url.addQueryItem("scope", scopes)
return str(url.toEncoded())
示例3: show_change_log
# 需要导入模块: from PyQt4.QtCore import QUrl [as 别名]
# 或者: from PyQt4.QtCore.QUrl import setPath [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_()
示例4: urlFromValue
# 需要导入模块: from PyQt4.QtCore import QUrl [as 别名]
# 或者: from PyQt4.QtCore.QUrl import setPath [as 别名]
def urlFromValue(self, value):
variable = value.variable
origin = variable.attributes.get("origin", "")
if origin and QDir(origin).exists():
origin = QUrl.fromLocalFile(origin)
elif origin:
origin = QUrl(origin)
if not origin.scheme():
origin.setScheme("file")
else:
origin = QUrl("")
base = origin.path()
if base.strip() and not base.endswith("/"):
origin.setPath(base + "/")
name = QUrl(str(value))
url = origin.resolved(name)
if not url.scheme():
url.setScheme("file")
return url