PyQt calling an external app?

Discussion in 'Python' started by gregarican, Jan 9, 2006.

  1. gregarican

    gregarican Guest

    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?
    gregarican, Jan 9, 2006
    #1
    1. Advertising

  2. gregarican

    Paul Boddie Guest

    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
    Paul Boddie, Jan 9, 2006
    #2
    1. Advertising

  3. gregarican

    gregarican Guest

    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!
    gregarican, Jan 9, 2006
    #3
  4. 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
    Giovanni Bajo, Jan 10, 2006
    #4
  5. gregarican

    gregarican Guest

    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 :)
    gregarican, Jan 10, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ulysses
    Replies:
    4
    Views:
    757
    Werner Schiendl
    Oct 22, 2003
  2. davout
    Replies:
    0
    Views:
    320
    davout
    Aug 4, 2004
  3. Replies:
    1
    Views:
    393
    Patrice
    Feb 9, 2007
  4. Marcpp

    Pyqt calling custom dialog

    Marcpp, Apr 12, 2007, in forum: Python
    Replies:
    0
    Views:
    400
    Marcpp
    Apr 12, 2007
  5. Marcpp
    Replies:
    3
    Views:
    1,448
    Marcpp
    Apr 17, 2007
Loading...

Share This Page