Explore Pyside's QWebView

vegaseat 2 Tallied Votes 694 Views Share

The Pyside GUI toolkit (public PyQt) lets you bring up an interactive web page with its QWebView widget. Here is a simple example.

''' ps_WebView102.py
explore PySide.QtWebKit.QWebView()
display an interactive website
tested with Python27 and Python34  by  vegaseat  10sep2014
'''

from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtWebKit import *

# create an application
app = QApplication([])

# add a window
win = QWidget()
# setGeometry(x_pos, y_pos, width, height)
win.setGeometry(100, 50, 700, 500)
win.setWindowTitle('Exploring PySide.QtWebKit.QWebView')

# use a simple vertical box layout
layout = QVBoxLayout()
win.setLayout(layout)

# create a QWebView instance
view = QWebView()

# load it with a URL (will be interactive)
url = "https://www.google.com/?gws_rd=ssl"
view.setUrl(QUrl(url))

layout.addWidget(view)

# show the window and run the app
win.show()
app.exec_()