I am playing with PySide开发者_StackOverflow社区 and QWebView to provide a WebKit version of a webapp on Windows.
Simple and easy to install in a complex working Windows environment where only Internet Explorer exists.
More over using QWebKit it is quite simple :
#!/usr/bin/env python
#-*- coding:utf-8 -*-
# hellowebkit.py
# Copyright 2009 Piotr Maliński, riklaunim@gmail.com
#
# <Under GPL licence>
import sys
from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtWebKit import *
app = QApplication(sys.argv)
web = QWebView()
web.load(QUrl("http://myapp.example.com"))
web.show()
sys.exit(app.exec_())
I would like to enable double buffering so that there is no drawing until the next page is fully loaded.
Do you know how I should do that?
I guess maybe using web.loadFinished()
signal?
Cheers,
Natim
You can use a QStackedWidget
and a QSignalMapper
to do that:
import sys
from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtWebKit import *
app = QApplication(sys.argv)
# Create a stack with 2 webviews
stack = QStackedWidget()
mapper = QSignalMapper(stack)
mapper.mapped[int].connect(stack.setCurrentIndex)
for i in range(2):
web = QWebView(stack)
stack.addWidget(web)
# When a webview finishes loading, switch to it
web.loadFinished[bool].connect(mapper.map)
mapper.setMapping(web, i)
# load the page in the non visible webview
stack.widget(1).load(QUrl("http://myapp.example.com"))
stack.show()
sys.exit(app.exec_())
精彩评论