tags:

views:

22

answers:

2

I'm using the KHTMLPart component from the PyKDE (in Python) library to download some webpages in the background and return sizes of certain elements in pixels. I don't really need any visual output from this script, indeed I will probably run it on a server without X installed. The problem is that when I tell my application to run console-only like this:

app = QApplication(sys.argv, False)

my script then segfaults on the line where I initialize KHTMLPart:

browser = KHTMLPart()

Additionally, I need to set the size of the KHTML browser window to 1024x768 by calling:

browser.view.resize(1024, 768)

This doesn't seem to have any effect until I call:

browser.show()

The previous causes the browser window to appear, even if that's for a short while. I could run a simple window manager such as fluxbox on the server and it will do what I want, but I'd be much happier if it were able to function completely as a console application - if that's even possible. Is there a way to achieve this?

+1  A: 

If all else fails, you could try using the X Virtual Framebuffer to provide a fake X display to your application, allowing it to run without displaying anywhere.

Mr. Shiny and New
+1  A: 

I doubt it. Most browsers separate the download, the creation of the DOM model and the rendering in different parts of the code. This allows them to download the data in threads, convert it and then use an optimized renderer to display it. This is an expensive operation so they only do it when necessary.

Therefore, I see no way around the fact that you need a running X server. But that server doesn't need to use the display. You can run the command vncserver for this. It will tell you the value you'll seed in for the DISPLAY variable to make your code access this hidden screen.

Aaron Digulla