As I understand it, the webview doesn't actually load the page and update
itself until the method call returns; at which point it loads the new page and
updates the history.
To illustrate the problem I'm having a little more clearly, I've
attached a sample script. The script is supposed to conduct a brief
tour of a list of websites when you hit the "go" button on the browser
toolbar. Each site shows for five seconds, then the next on loads.
Only that's not what happens. If you run it, you'll see that hitting
"go" causes the browser to hang for about 20 seconds, then the final
comment is all that shows. In other words, for the whole duration of
the method call, the main window is asleep.
I guess this is just another instance of the trouble I was running into
on my other program, which I posted a demonstration script for earlier
today. I would really appreciate any help on this matter.
#!/usr/bin/python
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
from time import sleep
import sys
class MyBrowser(QMainWindow):
"""My Browser demonstrates a problem I'm having with manipulating a webview via called methods
"""
def __init__(self):
"""
Build a browser workshop
"""
super(QMainWindow, self).__init__()
self.webview = QWebView()
self.setCentralWidget(self.webview)
self.navbar = self.addToolBar("Navigation")
#Not totally necessary, but let's make it look like a browser
self.navbar.addAction(self.webview.pageAction(QWebPage.Back))
self.navbar.addAction(self.webview.pageAction(QWebPage.Forward))
self.navbar.addAction(self.webview.pageAction(QWebPage.Reload))
self.navbar.addAction(self.webview.pageAction(QWebPage.Stop))
self.go_button = QPushButton("Go")
self.navbar.addWidget(self.go_button)
self.connect(self.go_button, SIGNAL("clicked()"), self.tour_of_internet)
self.webview.setHtml("<p>Click 'go' to get a tour of the best sites on the Internet.</p>")
def tour_of_internet(self):
"""
This is supposed to give you a tour of several sites, for five seconds each.
"""
sites = ["http://www.google.com", "http://doc.qt.nokia.com", "http://www.alandmoore.com", "http://www.kde.org"]
for site in sites:
self.webview.setUrl(QUrl(site))
self.webview.update()
sleep(5)
self.webview.setHtml("<p>Wow, wasn't that awesome???</p>")
if __name__ == '__main__':
app = QApplication(sys.argv)
w = MyBrowser()
w.show()
app.exec_()
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt