473,378 Members | 1,426 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

PyQt calling an external app?

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?

Jan 9 '06 #1
4 5226
gregarican wrote:

[os.system using the start command on Windows]
When I use this the PyQt app freezes up and only when I forcefully
close it does the browser window pop up.


What does os.startfile do when invoked with the URL? My impression was
that the startfile function - available only on Windows - doesn't wait
for the command to finish, but I don't run Windows and can't test this.
Any feedback would be appreciated, though, since it's part of the
desktop module I proposed a while back:

http://www.python.org/pypi/desktop

Paul

Jan 9 '06 #2
Paul Boddie wrote:
What does os.startfile do when invoked with the URL? My impression was
that the startfile function - available only on Windows - doesn't wait
for the command to finish, but I don't run Windows and can't test this.
Any feedback would be appreciated, though, since it's part of the
desktop module I proposed a while back:

http://www.python.org/pypi/desktop
Paul


Thanks! That worked perfectly. Sorry for all of the n00b questions, as
I'm only about a week or two into learning Python. I had about 1+ year
of experience coding in Ruby and am trying to translate a Qt app I
wrote in Ruby into Python. So there are some differences in each
language's Qt implementation. So far I am very impressed with Python's
maturity in terms of language consistency and available libraries. Plus
everyone is very responsive within the community.

Thanks again!

Jan 9 '06 #3
gregarican wrote:
What's the easiest and cleanest way of having PyQt bring up an
external application?


You can also go the Qt way and use QProcess. This also gives you cross-platform
communication and process killing capabilities which are pretty hard to obtain
(see the mess in Python with popen[1234]/subprocess). You also get nice signals
from the process which interact well in a Qt environment.
--
Giovanni Bajo
Jan 10 '06 #4
Giovanni Bajo wrote:
You can also go the Qt way and use QProcess. This also gives you cross-platform
communication and process killing capabilities which are pretty hard to obtain
(see the mess in Python with popen[1234]/subprocess). You also get nice signals
from the process which interact well in a Qt environment.
--
Giovanni Bajo


Good point. I don't think that this particular class is available with
Qt 2.3.0, which is what I am using for my Sharp Zaurus and Win32
implementations of this app. Once I move up to the world of Qt 4 I will
definitely look into this as an option for certain things. My next
quest will be rewriting this app (again) so that it will run on Windows
Mobile PDA's using Python and Tkinter for the GUI. Since all of the
data pushes/pulls relies on XMLRPC it shouldn't be too daunting. Just
need to present the data nicely :-)

Jan 10 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Ilya Knizhnik | last post by:
Dear All, I am fairly new to Python. I have found it an easy language to learn and a very usefull one for many tasks. Currently I am working on a python project that involves a GUI and it was...
2
by: Srinath Avadhanula | last post by:
Hello, I am wondering if QT has something like QWaitForNextEvent() function. This function would block execution of the application till another key was pressed and then return the event...
35
by: Vamsi Mudrageda | last post by:
I am kind of new to Python, and after trying and using wxPython, I found it kind of lacking in easy-to-read documentation, speed at loading, and GUI response-time. So I am looking for an another...
8
by: simo | last post by:
OK, so I'm at the stage where I want to make a choice between wxPython and PyQt. Currently I'm using wxPython mainly due to the fact that it has GPL Linux and Windows versions. I prefer Qt to...
10
by: svenn.are | last post by:
Hi, I wanted to run a program that is written in PyQt on my mac, and went over to Riverbank to get PyQ 3.13 and SIP 4.1.1 sources. I followed the installation guide except for the compiling...
3
by: Fabio | last post by:
Hi all, I'm about to write an application, and I'd like to use PyQt, but before choosing this toolkit I would like to clarify some particular licensing issues; if some user has already touched...
10
by: Simon John | last post by:
After quite a while of wxPython I'm getting back into PyQt, mainly due to the announcement by Trolltech that they will make a GPL version of Qt4 for Windows (and Phil-T said he will make a PyQt to...
3
by: Phil Thompson | last post by:
Riverbank Computing is pleased to announce the release of PyQt v4.0beta1 available from http://www.riverbankcomputing.co.uk/pyqt/. PyQt is a comprehensive set of Qt bindings for the Python...
6
by: king kikapu | last post by:
Hi, this is actually goes to whoever is using Eclipse and Eric4, the IDE that comes bundled with PyQt. I was using Eclipse until i saw Eric4 and i started experiment with it, very nice work. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.