本文整理汇总了Python中PySide.QtCore.QUrl.toString方法的典型用法代码示例。如果您正苦于以下问题:Python QUrl.toString方法的具体用法?Python QUrl.toString怎么用?Python QUrl.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtCore.QUrl
的用法示例。
在下文中一共展示了QUrl.toString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ImageRenderer
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import toString [as 别名]
class ImageRenderer(QObject):
def __init__(self, url, image_path):
QObject.__init__(self)
self.url = QUrl(url)
self.image_path = image_path
self.webpage = QWebPage(self)
self.webpage.loadFinished.connect(self.render)
self.webpage.mainFrame().load(self.url)
def render(self, ok):
if ok:
print('Loaded {0}'.format(self.url.toString()))
self.webpage.setViewportSize(
self.webpage.mainFrame().contentsSize())
image = QImage(self.webpage.viewportSize(),
QImage.Format_ARGB32)
painter = QPainter(image)
self.webpage.mainFrame().render(painter)
painter.end()
if image.save(self.image_path):
print('Saved image to {0}'.format(self.image_path))
else:
print('Could not save to {0}'.format(self.image_path))
else:
print('Could not load {0.toString()}'.format(self.url))
QApplication.instance().quit()
示例2: linkClicked
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import toString [as 别名]
def linkClicked(self, url):
fragment = None
if url.hasFragment():
fragment = url.fragment()
_url = QUrl(url.toString()[:url.toString().find('#%s'%fragment)])
if _url.toString() != 'about:blank' and _url.path() != self.current_position:
url = _url
fragment = None
if fragment:
page = self.view.page()
page.mainFrame().scrollToAnchor(fragment)
elif url.path() in self.contents.keys():
self.current_position = url.path()
self.loadPage(self.contents[url.path()])
elif url.path().startswith('http://') or url.path().startswith('www.'):
print 'pass the address to the system browser'
示例3: testSetAttributes
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import toString [as 别名]
def testSetAttributes(self):
#Construct QUrl by set* methods
url = QUrl()
url.setScheme('ftp')
self.assertEqual(url.toString(), 'ftp:')
url.setHost('www.google.com')
self.assertEqual(url.toString(), 'ftp://www.google.com')
url.setPort(8080)
self.assertEqual(url.toString(), 'ftp://www.google.com:8080')
url.setPath('mail/view')
self.assertEqual(url.toString(),
'ftp://www.google.com:8080/mail/view')
url.setUserName('john')
self.assertEqual(url.toString(),
'ftp://[email protected]:8080/mail/view')
url.setPassword('abc123')
self.assertEqual(url.toString(),
'ftp://john:[email protected]:8080/mail/view')
示例4: testBasic
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import toString [as 别名]
def testBasic(self):
#Default constructor for QUrl
url = QUrl()
self.assertEqual(url.toString(), "")
示例5: Navigator
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import toString [as 别名]
class Navigator(Singleton,object):
instance = None
logger = None
PATH_SEPARATOR = '-'
JUMP_SIGNAL_PAGE_LOAD_FINISH = 'PAGE LOAD FINISH'
JUMP_SIGNAL_REQUEST_LOAD_FINISH = 'REQUEST LOAD FINISH'
CROSS_AXIS_METHOD_AJAX = 'AJAX'
CROSS_AXIS_METHOD_FULL_LOAD = 'FULL LOAD'
def __init__(self):
self.network_manager = CustomNetworkAccessManager.getInstance()
self.axis = []
self.human_events = {}
self.node_collected_data = {}
self.last_url = None
self.current_url = QUrl()
self.current_axis_id = None
self.crossed_axis_method = None
self.crossed_axes = []
self.crossed_axes_string = ''
self.cross_axis_delay = QTimer()
self.cross_axis_delay.setSingleShot(True)
self.cross_axis_delay.timeout.connect(self.crossedAxis)
self.cross_axis_params = None
self.loading_timeout = QTimer()
self.loading_timeout.setSingleShot(True)
self.loading_timeout.setInterval(30000)
self.loading_timeout.timeout.connect(self.loadingTimeoutAction)
self.inactivity_timeout = QTimer()
self.inactivity_timeout.setSingleShot(True)
self.inactivity_timeout.setInterval(10000)
self.inactivity_timeout.timeout.connect(self.inactivityTimeoutAction)
self.page_reloads = 0
Logger.getLoggerFor(self.__class__)
def takeEntryPoint(self):
g = GraphParser.getInstance()
for ax in self.axis:
self.logger.info('Axis : %s' % ax)
if g.entry_point:
self.logger.info('Taking the entry point %s' % g.entry_point)
self.last_url = QUrl(g.entry_point)
inst = Jaime.getInstance()
inst.view.load(QUrl(g.entry_point))
return True
self.logger.error("Can't take entry point, graph has't entry point")
return False
def matchesSelector(self,axis):
inst = Jaime.getInstance()
frame = inst.view.page().mainFrame()
document = frame.documentElement()
selector = axis.css_selector_condition
# print 'document %s ' % document.evaluateJavaScript("""this.querySelector('%s')""" % selector)
ret = frame.findAllElements(selector)
print '%s axis %s matches css selector ? %s' % (selector,axis,bool(ret.count()))
self.logger.debug('axis %s matches css selector ? %s' % (axis,bool(ret.count())))
# for i in range(ret.count()):
# self.logger.error(ret.at(i).toInnerXml())
return ret.count()
def matches(self,axis):
m_from = False
m_to = False
m_method = True
m_selector = True
m_route = True
if axis.from_url is not None :
if isinstance(axis.from_url,str):
m_from = axis.from_url == self.last_url.toString()
elif axis.from_url.match(self.last_url.toString()):
m_from = True
else:
m_from = True
if axis.to_url is not None:
if isinstance(axis.to_url,str):
m_to = axis.to_url == self.current_url.toString()
elif axis.to_url.match(self.current_url.toString()):
m_to = True
else:
m_to = True
# print 'el axis %s tiene method %s, %s ' % (axis,
# axis.axis_method,
# self.crossed_axis_method
# )
#.........这里部分代码省略.........