本文整理汇总了Python中PySide.QtWebKit.QWebView.show方法的典型用法代码示例。如果您正苦于以下问题:Python QWebView.show方法的具体用法?Python QWebView.show怎么用?Python QWebView.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtWebKit.QWebView
的用法示例。
在下文中一共展示了QWebView.show方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Robot
# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import show [as 别名]
class Robot(object):
def __init__(self):
self.view = QWebView()
self.page = self.view.page()
def start(self):
self.view.show()
QtCore.QObject.connect(self.view,
QtCore.SIGNAL("loadFinished(bool)"),
self.loaded)
self.view.load(QUrl('https://login.yahoo.com/config/login_verify2?&.src=ym'))
def loaded(self):
url = self.view.url().toString()
self.view.show()
print "Loading %s finished" % url
frame = self.page.mainFrame()
els = frame.findAllElements("a[id*='copyright']")
for i in range(els.count()):
print 'Plain Text [%s]' % els.at(i).toPlainText().encode('utf8','ignore')
print 'inner xml %s' % els.at(i).toInnerXml()
child_els = els.at(i).findAll('*')
for j in range(child_els.count()):
print 'childs inner xml [%s] ' % child_els.at(j).toInnerXml()
示例2: HTMLApplication
# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import show [as 别名]
class HTMLApplication(object):
def show(self):
#It is IMPERATIVE that all forward slashes are scrubbed out, otherwise QTWebKit seems to be
# easily confused
kickOffHTML = join(dirname(__file__).replace('\\', '/'), "templates/index.html").replace('\\', '/')
#This is basically a browser instance
self.web = QWebView()
#Unlikely to matter but prefer to be waiting for callback then try to catch
# it in time.
self.web.loadFinished.connect(self.onLoad)
self.web.load(kickOffHTML)
self.web.show()
def onLoad(self):
#This is the body of a web browser tab
self.myPage = self.web.page()
self.myPage.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
#This is the actual context/frame a webpage is running in.
# Other frames could include iframes or such.
self.myFrame = self.myPage.mainFrame()
# ATTENTION here's the magic that sets a bridge between Python to HTML
self.myFrame.addToJavaScriptWindowObject("eth", self.ethclient)
#Tell the HTML side, we are open for business
self.myFrame.evaluateJavaScript("ApplicationIsReady()")
示例3: TestJsCall
# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import show [as 别名]
class TestJsCall(UsesQApplication):
@classmethod
def setUpClass(self):
super(TestJsCall, self).setUpClass()
def createInstance(self):
global functionID
self._view = QWebView()
self._jsfuncs = JSFuncs()
functionID = -1
self._view.page().mainFrame().addToJavaScriptWindowObject("jsfuncs", self._jsfuncs)
self._view.loadFinished[bool].connect(self.onLoadFinished)
self._view.load(PAGE_DATA % FUNCTIONS_LIST[self._functionID])
self._view.show()
def testJsCall(self):
self._functionID = 0
self.createInstance()
self.app.exec_()
def onLoadFinished(self, result):
global functionID
self.assertEqual(self._functionID, functionID)
if self._functionID == (len(FUNCTIONS_LIST) - 1):
QTimer.singleShot(300, self.app.quit)
else:
#new test
self._functionID += 1
self.createInstance()
示例4: browse
# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import show [as 别名]
def browse(url, name='', icon=''):
from PySide.QtGui import QApplication, QIcon
from PySide.QtCore import QUrl
from PySide.QtWebKit import QWebView
for try_ in range(10):
try:
assert urllib2.urlopen(url).code == 200
except (AssertionError, urllib2.URLError):
time.sleep(0.25)
else:
print "Started Qt Web View after %i ticks." % try_
break
else:
sys.exit("Error initializing Qt Web View.")
qtapp = QApplication(name)
web = QWebView()
web.load(QUrl(url))
if icon:
print "Setting Icon to", icon
web.setWindowIcon(QIcon(icon))
else:
print "WARNING: No icon found in settings.py"
web.setWindowTitle(name)
web.show()
qtapp.exec_()
示例5: WebMediaView
# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import show [as 别名]
class WebMediaView(MediaView):
def __init__(self, media, parent):
super(WebMediaView, self).__init__(media, parent)
self._widget = QWebView(parent)
self._widget.setGeometry(media['_geometry'])
self.set_default_widget_prop()
self._widget.setDisabled(True)
self._widget.page().mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)
self._widget.page().mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
@Slot()
def play(self):
self._finished = 0
path = "%s/%s_%s_%s.html" % (
self._save_dir,
self._layout_id, self._region_id, self._id
)
self._widget.load("about:blank")
if 'webpage' == str(self._type) and 'native' == str(self._render):
url = self._options['uri']
self._widget.load(QUrl.fromPercentEncoding(url))
else:
self._widget.load('file://' + path)
self._widget.show()
self._widget.raise_()
self._play_timer.setInterval(int(float(self._duration) * 1000))
self._play_timer.start()
self.started_signal.emit()
示例6: testQVariantListProperty
# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import show [as 别名]
def testQVariantListProperty(self):
class Obj(object):
list = ['foo', 'bar', 'baz']
obj = Obj()
wrapper_dict = {}
for name in ['list']:
getter = lambda arg=None, name=name: getattr(obj, name)
wrapper_dict[name] = Property('QVariantList', getter)
wrapper = type('PyObj', (QObject,), wrapper_dict)
view = QWebView()
frame = view.page().mainFrame()
frame.addToJavaScriptWindowObject('py_obj', wrapper())
html = '''
<html><body>
<script type="text/javascript">
document.write(py_obj.list)
</script>
</body></html>
'''
view.setHtml(html)
view.show()
self.app.exec_()
示例7: createWebView
# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import show [as 别名]
def createWebView( nIndex ):
global functionID
global currentWebView
functionID = nIndex
currentWebView = QWebView()
currentWebView._jsfuncs = JSFuncs()
currentWebView.page().mainFrame().addToJavaScriptWindowObject("jsfuncs", currentWebView._jsfuncs)
QObject.connect( currentWebView, QtCore.SIGNAL('loadFinished( bool )'), onLoadFinished )
currentWebView.load(PAGE_DATA % FUNCTIONS_LIST[ nIndex ])
currentWebView.show()
示例8: main
# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import show [as 别名]
def main():
app = QApplication(sys.argv)
view = QWebView()
frame = view.page().mainFrame()
printer = ConsolePrinter()
view.setHtml(html)
frame.addToJavaScriptWindowObject('printer', printer)
frame = frame
#frame.evaluateJavaScript("alert('Hello');")
#frame.evaluateJavaScript("printer.text('Goooooooooo!');")
view.show()
app.processEvents()
app.exec_()
示例9: testPlugin
# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import show [as 别名]
def testPlugin(self):
view = QWebView()
fac = PluginFactory()
view.page().setPluginFactory(fac)
QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)
view.load(QUrl(os.path.join(os.path.abspath(os.path.dirname(__file__)), "qmlplugin", "index.html")))
view.resize(840, 600)
view.show()
QTimer.singleShot(500, self.app.quit)
self.app.exec_()
示例10: main
# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import show [as 别名]
def main():
app = QApplication([])
view = QWebView()
fac = PluginFactory()
view.page().setPluginFactory(fac)
QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)
view.load(QUrl(sys.argv[1]))
view.resize(840, 600)
view.show()
return app.exec_()
示例11: main
# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import show [as 别名]
def main():
app = QApplication([])
webview = QWebView()
loop = QEventLoop()
webview.loadFinished.connect(loop.quit)
webview.load(QUrl('http://example.webscraping.com/search'))
loop.exec_()
webview.show()
frame = webview.page().mainFrame()
frame.findFirstElement('#search_term').setAttribute('value', '.')
frame.findFirstElement('#page_size option:checked').setPlainText('1000')
frame.findFirstElement('#search').evaluateJavaScript('this.click()')
elements = None
while not elements:
app.processEvents()
elements = frame.findAllElements('#results a')
countries = [e.toPlainText().strip() for e in elements]
print countries
示例12: Web
# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import show [as 别名]
class Web(QtGui.QWidget):
def __init__(self):
super(Web, self).__init__()
global clear
clear = lambda: os.system('cls')
self.initUI()
def initUI(self):
# Plugin
QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)
self.b = QWebView()
PGrupo = None
PID = None
Pregunta = input("Elige [ ID ] o [ GRUPO ] (Respeta mayúsculas) : ")
if Pregunta == "GRUPO":
clear()
PGrupo = input("Escribe el nombre del [ GRUPO ] : ")
self.b.load(QUrl("http://xat.com/"+PGrupo))
elif Pregunta == "ID":
clear()
PID = int(input("Escribe la [ID] : "))
self.b.load(QUrl("http://xat.com/web_gear?id="+PID))
else:
print("Asi no idiota")
return self.initUI()
self.b.setWindowTitle('SearchXat')
# Icon
#self.b.setWindowIcon(QtGui.QIcon('icon.png'))
self.b.show()
示例13: MapApp
# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import show [as 别名]
class MapApp(QWidget):
def __init__(self, parent=None):
# call QWidget's __init__
super(MapApp, self).__init__(parent)
self.setWindowTitle("Map Application")
f = open("map.html", "r")
html = f.read()
f.close()
# declare our QWebView and set the URL to the source of the map.html file.
# we must also set a URL (which QtWebKit will use if we ask for the URL of the page)
self.webView = QWebView()
self.webView.setHtml(html, baseUrl=QUrl("http://local"))
self.webView.show()
self.location = QLineEdit()
self.go = QPushButton("Find this location")
self.go.clicked.connect(self.findLocation)
# set up our layout and add the instance of the QWebView
self.mainLayout = QGridLayout()
self.mainLayout.addWidget(self.location)
self.mainLayout.addWidget(self.go)
self.mainLayout.addWidget(self.webView)
self.setLayout(self.mainLayout)
def findLocation(self):
page = self.webView.page()
frame = page.mainFrame()
# the javascript code to be executed
functionCall = 'codeAddress("' + self.location.text() + '")'
# execute the javascript code in the webkit instance
frame.evaluateJavaScript(functionCall)
示例14: Application
# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import show [as 别名]
class Application(object):
def show(self):
self.battery = Battery()
self.wifi = Wifi()
self.url = QUrl("qt.html")
self.web = QWebView()
self.web.loadFinished.connect(self.onLoad)
self.web.load(self.url)
self.web.show()
def onLoad(self):
self.page = self.web.page()
self.page.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
self.frame = self.page.mainFrame()
self.frame.addToJavaScriptWindowObject("battery", self.battery)
self.frame.addToJavaScriptWindowObject("wifi", self.wifi)
self.frame.evaluateJavaScript("isReady()")
self.wifi.loop.run()
示例15: qt_method
# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import show [as 别名]
class qt_method(common_method):
def create_browser(self):
try:
from PySide.QtCore import QUrl
from PySide.QtGui import QApplication
from PySide.QtWebKit import QWebView
except ImportError:
raise self.raise_error("You need python-pyside\nDownload: http://developer.qt.nokia.com/wiki/PySide_Binaries_Linux")
self.app = QApplication(sys.argv)
self.web = QWebView()
self.web.load(QUrl(self.OAUTH_URL))
self.web.loadFinished[bool].connect(self.load_finished)
self.web.show()
self.app.exec_()
def get_url(self):
return self.web.url().toString()
def destroy(self):
self.web.close()
self.app.exit()