I have an application that displays a webpage in an iframe, and then loads the X number of images in a div that overlays the frame.
So, I have this python script that loads the url and takes a screenshot. It works on regular web pages, but I think the frame discards it. Below is my code and a link to a snapshot of it.
import sys
import signal
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import QWebPage
def onLoadFinished(result):
if not result:
print "Request failed"
sys.exit(1)
size = webpage.mainFrame().contentsSize()
webpage.setViewportSize(webpage.mainFrame().contentsSize())
image = QImage(webpage.viewportSize(), QImage.Format_ARGB32)
painter = QPainter(image)
webpage.mainFrame().render(painter)
painter.end()
image.save("/var/www/html/output.png")
sys.exit(0)
qtargs = [sys.argv[0]]
qtargs.append("-display")
qtargs.append(":0")
app = QApplication(qtargs,True)
signal.signal(signal.SIGINT, signal.SIG_DFL)
webpage = QWebPage()
webpage.mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
webpage.mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)
webpage.connect(webpage, SIGNAL("loadFinished(bool)"), onLoadFinished)
webpage.mainFrame().load(QUrl("http://localhost/heatmap"))
sys.exit(app.exec_())
Screenshot:
http://img28.imageshack.us/img28/7506/outputc.png
, , iframe div . - , ? Qt.ScrollbarAlwaysOff . "-" -, - , , .
webpage.mainFrame(). contentsSize() ,
PyQt4.QtCore.QSize(400, 158)
- www.google.com,
PyQt4.QtCore.QSize(617, 573)
, - , contentSize(). , ?