PyQt calling an external app?

gregarican greg.kujawa at gmail.com
Mon Jan 9 11:44:08 EST 2006


What's the easiest and cleanest way of having PyQt bring up an external
application? In this case I am looking to launch Internet Explorer and
bring up a specific URL. I don't care about tracking the IE process'
activity and don't want PyQt to wait until the browser is closed. I
tried the following code from within a PyQt app:

import os

url = 'http://server.domain.com/page.html'
os.system('start %s' % url)

When I use this the PyQt app freezes up and only when I forcefully
close it does the browser window pop up. Then I looked into QThreads
and some other choices. Here's my latest attempt, using win32process:

import win32process

url='http://server.domain.com/page.html'
cmd_line = 'start %s' % url
win32process.CreateProcess(None, cmd_line, None, None,
1,win32process.CREATE_NEW_CONSOLE, None, None,
win32process.STARTUPINFO())

When I try this I get a message stating 'The system cannot find the
file specified' when the cmd_line is being interpreted. I am using
Python 2.3.5 on Windows 2000 Professional, with Qt 2.3.0 and PyQt 3.13.
Do I have to go to the lengths of implementing a QThread just to spawn
an external program I don't care about tracking?




More information about the Python-list mailing list