本文整理汇总了Python中PyQt4.QtCore.QUrl.setScheme方法的典型用法代码示例。如果您正苦于以下问题:Python QUrl.setScheme方法的具体用法?Python QUrl.setScheme怎么用?Python QUrl.setScheme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QUrl
的用法示例。
在下文中一共展示了QUrl.setScheme方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_url
# 需要导入模块: from PyQt4.QtCore import QUrl [as 别名]
# 或者: from PyQt4.QtCore.QUrl import setScheme [as 别名]
def load_url(self, url):
basename = os.path.basename(unicode(url.toString()))
path = os.path.join(settings.get('help_path'), basename)
if not os.path.exists(path):
messagebox = RUrlLoadingErrorMessageBox(self)
messagebox.exec_()
else:
if not url.scheme() in ['http', 'ftp']:
url = QUrl(os.path.abspath(os.path.join(settings.get('help_path'), basename)).replace('\\', '/'))
url.setScheme('file')
self.ui.webView.load(url)
else:
messagebox = RUrlLoadingErrorMessageBox(self)
messagebox.exec_()
示例2: get_authorization_url
# 需要导入模块: from PyQt4.QtCore import QUrl [as 别名]
# 或者: from PyQt4.QtCore.QUrl import setScheme [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: BaseInventoryProvider
# 需要导入模块: from PyQt4.QtCore import QUrl [as 别名]
# 或者: from PyQt4.QtCore.QUrl import setScheme [as 别名]
class BaseInventoryProvider(HelpProvider):
def __init__(self, inventory, parent=None):
super().__init__(parent)
self.inventory = QUrl(inventory)
if not self.inventory.scheme() and not self.inventory.isEmpty():
self.inventory.setScheme("file")
self._error = None
self._fetch_inventory(self.inventory)
def _fetch_inventory(self, url):
cache_dir = config.cache_dir()
cache_dir = os.path.join(cache_dir, "help", type(self).__qualname__)
try:
os.makedirs(cache_dir)
except OSError:
pass
url = QUrl(self.inventory)
if not url.isLocalFile():
# fetch and cache the inventory file.
manager = QNetworkAccessManager(self)
cache = QNetworkDiskCache()
cache.setCacheDirectory(cache_dir)
manager.setCache(cache)
req = QNetworkRequest(url)
self._reply = manager.get(req)
manager.finished.connect(self._on_finished)
else:
self._load_inventory(open(str(url.toLocalFile()), "rb"))
def _on_finished(self, reply):
if reply.error() != QNetworkReply.NoError:
log.error("An error occurred while fetching "
"help inventory '{0}'".format(self.inventory))
self._error = reply.error(), reply.errorString()
else:
contents = bytes(reply.readAll())
self._load_inventory(io.BytesIO(contents))
def _load_inventory(self, stream):
raise NotImplementedError()
示例4: onSavClick
# 需要导入模块: from PyQt4.QtCore import QUrl [as 别名]
# 或者: from PyQt4.QtCore.QUrl import setScheme [as 别名]
def onSavClick(self):
if self.urlEdit.text().isEmpty():
self.urlEdit.setText(self.tr("insert URL here"))
self.urlEdit.selectAll()
else:
u = QUrl()
u.setUrl(self.urlEdit.text())
if not u.scheme():
u.setScheme('http')
u.setUserName(self.name.text())
u.setPassword(self.passwd.text())
self.config.saveLink(self.nameSelect.currentText(), { 'type' : self.typeSelect.currentText(), 'data' : u.toString()})
#self.links = self.config.loadLinks()
self.savButton.setFont(QFont())
self.modified.append(str(self.nameSelect.currentText()))
示例5: urlFromValue
# 需要导入模块: from PyQt4.QtCore import QUrl [as 别名]
# 或者: from PyQt4.QtCore.QUrl import setScheme [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