This is a post from my original site, which was hosted by the former blog service of the University of Osnabrück. I have moved it to the new site for archiving. Pages linked in this article may no longer work today, and the blog comments under the article no longer exist. Opinions expressed in this article reflect the point of view of the time of publication and do not necessarily reflect my opinion today.
If you need flash support, you should have a look at the current github version of this script at http://github.com/AdamN/python-webkit2png/ mentioned above. We've extend the script a few month ago.
From time to time you may want to create a screenshot of a web page from command line, for example if you wish to create thumbnails for your web-application. So you might search for such a program and find tools like webkit2png, which is for Mac OS X only, or khtml2png, which requires a lot of KDE stuff to be installed on your server.
But since Qt Software, formerly known als Trolltech, integrated Safari's famous rendering engine WebKit (which is based on Konqueror's khtml engine) into its framework, we are now able to make use of it with the help of some Python and PyQt4.
Today I had to resolve a mysterious bug in a PyQt5 / QtWebEngine application. After the user unlocked his session, the application hangs for a while before resuming to normal activity. I've added an JavaScript interval that prints the current time once a second onto the console, but even through the timestamps were OK it seems that something had freezed the application while the screen was locked.
To make it short, the application requested a status update via WebChannel once a second. While the Javascript kept active, the event loop of QApplication was blocked, so that the WebChannel events were put into a queue. (The reason for the block was the change to a new VT by the light-locker lock screen - I was able emulate it by manually switching to VT1 after the application has been started). When the application got active again, Qt started to empty the queue before any new events were processed.