[wxPython] wxExecute?

0 views
Skip to first unread message

Guy N. Hurst

unread,
Nov 30, 1999, 3:11:49 AM11/30/99
to wxPython Post
Hi,

I have started out with a basic framework having Exit and About.
Next, I need to be able to run an external program from within the one I
am making.
(to download data from barcode scanner).

But I noticed in the documentation I have, that wxExecute is not listed
with the supported function classes for wxPython... :-(

Maybe it has since been added ?

I am not sure what to do next, so I turn to this mailing list.

Anyone have some pointers for me?

Thanks.

Guy N. Hurst
wxPython 2.1.11, Win95


_______________________________________________
wxPython-users maillist - wxPytho...@starship.python.net
http://starship.python.net/mailman/listinfo/wxpython-users


Ionel Simionescu

unread,
Nov 30, 1999, 11:50:35 AM11/30/99
to Guy N. Hurst, wxPython - List

----- Original Message -----
From: Guy N. Hurst <gnh...@hurstlinks.com>

| I have started out with a basic framework having Exit and About.
| Next, I need to be able to run an external program from within the one I
| am making.
| (to download data from barcode scanner).
|
| But I noticed in the documentation I have, that wxExecute is not listed
| with the supported function classes for wxPython... :-(
|
| Maybe it has since been added ?
|
| I am not sure what to do next, so I turn to this mailing list.
|
| Anyone have some pointers for me?

You may consider to look at:
Python Library, module os, the exec* family of functions.

(I guess that one does not really need wxExecute in wxPython when he can do
the same from Python.)

ionel

Markus Gritsch

unread,
Nov 30, 1999, 11:51:52 AM11/30/99
to Guy N. Hurst, wxPython-users list
"Guy N. Hurst" wrote:

> Hi,
>
> I have started out with a basic framework having Exit and About.
> Next, I need to be able to run an external program from within the one I
> am making.
> (to download data from barcode scanner).
>
> But I noticed in the documentation I have, that wxExecute is not listed
> with the supported function classes for wxPython... :-(
>
> Maybe it has since been added ?
>
> I am not sure what to do next, so I turn to this mailing list.
>
> Anyone have some pointers for me?

Maybe you would like to look at the Python library reference manual:
http://www.python.org/doc/current/lib/os-process.html

---
Markus

Robin Dunn

unread,
Nov 30, 1999, 11:51:34 AM11/30/99
to Guy N. Hurst, wxPython Post
> But I noticed in the documentation I have, that wxExecute is not listed
> with the supported function classes for wxPython... :-(
>

Python provides several good ways to execute other programs. Look in the
Python docs at the os module.

On the other hand, wxExecute is supported by wxPython. It's not listed in
the list of supported classes because it is not a class. I guess there needs
to be another page that lists the supported functions too.

--
Robin Dunn
Software Craftsman
ro...@AllDunn.com
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/ Check it out!

Winkelman, Jeff

unread,
Nov 30, 1999, 11:50:09 AM11/30/99
to Guy N. Hurst, wxPython Post
Guy,

Depending on what exactly you are trying to do with the external program you
want to launch, there are a few things you can use:

1) Look into the os module that comes with Python. This module has several
methods for process management. The most popular being os.popen().
However, there is the following problem taken from the Python FAQ:

7.13. Why doesn't os.popen() work in PythonWin on NT?
The reason that os.popen() doesn't work from within PythonWin is due to a
bug in Microsoft's C Runtime Library (CRT). The CRT assumes you have a Win32
console attached to the process.
You should use the win32pipe module's popen() instead which doesn't depend
on having an attached Win32 console.
Example:
import win32pipe
f = win32pipe.popen('dir /c c:\\')
print f.readlines()
f.close()

2) Since you are on a Windows platform, the win32 extensions that have been
created support several was to launch other programs or create additional
processes. One of these is demonstrated above.

Another example is the following I did to run the netstat command at the
command line from a python program:

import win32pipe, time, string

f = win32pipe.popen('netstat -e')
time.sleep(1)
line = f.readline()
if string.find(line, 'Bytes') != -1:
f.close()
return

Hope this gets you started. Information regarding the above can be found on
python.org, python's documentation, and the win32 extensions
documentation....


> -----Original Message-----
> From: Guy N. Hurst [SMTP:gnh...@hurstlinks.com]
> Sent: Tuesday, November 30, 1999 3:12 AM
> To: wxPython Post
> Subject: [wxPython] wxExecute?
>
> Hi,
>
> I have started out with a basic framework having Exit and About.
> Next, I need to be able to run an external program from within the one I
> am making.
> (to download data from barcode scanner).
>

> But I noticed in the documentation I have, that wxExecute is not listed
> with the supported function classes for wxPython... :-(
>

> Maybe it has since been added ?
>
> I am not sure what to do next, so I turn to this mailing list.
>
> Anyone have some pointers for me?
>

> Thanks.
>
> Guy N. Hurst
> wxPython 2.1.11, Win95
>
>

Guy N. Hurst

unread,
Dec 1, 1999, 12:50:07 AM12/1/99
to wxPython Post
Thanks to all who responded.

For some reason, I didn't think the os module was an option.
I have now tried both the os module and wxExecute (which does exist :-).

Both do work, but wxExecute handled more gracefully for what I was
trying to do.

Of course, I will need the os module functionality soon enough.
Thanks for all the pointers.

Guy N. Hurst

Harri Pasanen

unread,
Dec 5, 1999, 4:47:11 AM12/5/99
to Andrew Yinger, Guy N. Hurst, wxPython Post

-----Original Message-----
From: Guy N. Hurst <gnh...@hurstlinks.com>
To: Andrew Yinger <ayi...@mail.idrive.com>
Cc: wxPython Post <wxpytho...@server.python.net>
Date: Sunday, December 05, 1999 6:36 AM
Subject: Re: [wxPython] wxExecute?


>(cc to list)
>
>Hi,
>
>I liked wxExecute, because when it tried to run a bad command, it
>recovered well,
>whereas using os module on a bad command made my system crash HARD. (ok,
>maybe I should use try/except).
>But, when trying the simple copy command with wxExecute, it complained
>it couldn't find the file, whereas the os module executed the same
>command easily (os.system).
>


For copying files I suggest you take a look at Python standard module
'shutil'
That provides functions such as copyfile, copytree, etc.

On windows (NT) the cmd.exe, or command.com complicates life, as it
implements some commands internally. I would think that there is some way
to make wxExecute perform the copy by invoking cmd.exe with parameters, but
I suggest not to bother and use shutil.copy2 instead. wxExecute will
likely work well for windows applications with a corresponding exe. I think
os.system will use cmd.exe to do its work, and will thus flash a msdos
window while launching the command.

-Harri

Guy N. Hurst

unread,
Dec 4, 1999, 10:15:35 PM12/4/99
to Andrew Yinger, wxPython Post
(cc to list)

Hi,

I liked wxExecute, because when it tried to run a bad command, it
recovered well,
whereas using os module on a bad command made my system crash HARD. (ok,
maybe I should use try/except).
But, when trying the simple copy command with wxExecute, it complained
it couldn't find the file, whereas the os module executed the same
command easily (os.system).

Then I found the wxCopyFile function, among others -- but they must not
be implemented,
because when I tried this one, it gave me: "NameError: wxCopyFile".
Not only that, but it seems to use the wxString class, which is not in
the list of implemented classes.
wxGetCWD() doesn't work either...

I am definitely losing confidence in wxExecute.

As for the console window, I have that also - I have yet to discover how
to make that go away...

Anyone else have ideas?

Guy N. Hurst

Andrew Yinger wrote:
>
> Hi.
>
> As noted, wxExecute does not seem to be documented. Since it looks as
> if you are trying it out, can you clue me into what it does exactly? For
> example, could I use it for some of the functionality found in os.system()
> and os.popen()? (The reason I ask is that I have to run my wxPython app
> with a console window present because I need to use these os functions to
> execute some lame shell scripts -- if I do not run with a console window,
> these function calls do not appear to work!)
>
> Thanks,
>
> Andrew


>
> ----- Original Message -----
> From: Guy N. Hurst <gnh...@hurstlinks.com>

> To: wxPython Post <wxpytho...@server.python.net>
> Sent: Tuesday, November 30, 1999 9:50 PM
> Subject: Re: [wxPython] wxExecute?
>
> > Thanks to all who responded.
> >
> > For some reason, I didn't think the os module was an option.
> > I have now tried both the os module and wxExecute (which does exist :-).
> >
> > Both do work, but wxExecute handled more gracefully for what I was
> > trying to do.
> >
> > Of course, I will need the os module functionality soon enough.
> > Thanks for all the pointers.
> >
> > Guy N. Hurst
> >
> >

Cristian Echeverria

unread,
Dec 5, 1999, 6:30:17 PM12/5/99
to Guy N. Hurst, Andrew Yinger, wxPython Post
If you are on win95/98/NT you must see
spawnv (into the os module).
this function works only on windows and avoid the
console.

Cristian

----- Original Message -----
From: Guy N. Hurst <gnh...@hurstlinks.com>

To: Andrew Yinger <ayi...@mail.idrive.com>
Cc: wxPython Post <wxpytho...@server.python.net>

Reply all
Reply to author
Forward
0 new messages