On Sun, Jan 9, 2011 at 9:03 AM, ALAN GAULD <alan.ga...@btinternet.com> wrote: > > >> The following line is what I mean by calling a command line from within the >>app >> using subprocess. >> >> self.espeak = subprocess.Popen(['espeak', word],stdout = >> subprocess.PIPE).communicate()[0] > > OK, Now I understand. > You want to call an external application from within your code > via subprocess. And you want to know if that will work ok in a > wxPython application? > >> >> In other words, is a command line app different from >> >> bindings in a compiled app? > > When you call an app using subprocess it spawns an entirely > separate process in the OS. There is no linkage to your process > apart from the redirection of stdin/stdout/stderr back to your > app instead of to a console. > >> > So-called exe generators simply bundle the interpreter witrh >> > the code and auto run it. >> >> So it's basically just installing a sandbox version of python? > > Sort of, its a minimalist version of python with only the modules > needed to run the app. And you can't run the interpreter on its > own you can only run the packaged app. > >> Which ultimately is, if I have a standalone application, that doesn't >> come from a command line terminal launching(which I haven't gotten to >> yet), is using the command line calls going through subprocess going >> to be called without the terminal, or will it open a terminal >> automatically to make those calls? > > The app (eSpeak in your example) will see your app as its "console". > That is, it will send all output to your app and read all input from your > app
I was thinking that since the app is called from the command line with python(which is no different, than using any other command line script-just like espeak 'word' -> python script.py), it would be go back to the shell window it was spawned/called from through python and utilize the command line there. Similar to how when I run the app, my data can be through the app text/label fields, or, through the terminal window itself. (so you need to make sure it gets any input it is expecting!) > The other thing to watch in a wxPython (or any other GUI framework) > is that if the app runs for a long time your app may "freeze" from > the user's perspective, so you may want to run it in the background > or as a separate thread in your app. > >> Or will all of my python apps need to have a command line terminal >> open to launch them. > > No, your app takes over the job of the terminal. When you launch > a program from the terninal the terminal app(for it is just an app like > any other) is doing the same as you, it is spawning a subprocess > that sends its output back to the teminal for it to display. > > In fact you might find it a useful exercise to build a very basic terminal > app in wxPython first. Read commands from a command input field > and display the output in a text widget... Execute the commands > via subprocess. Its a good way to get used to using subprocess > and experimenting with its various options. If you are very keen > you can start adding command history and search etc to it too... > I'll eventually get to the above(I have a lot of projects, some will involve command line/subprocess:), but thanks for the explanation. I'm guessing that something like cxfreezeI haven't looked it over thoroughly) might be what I was looking for. Although in the end, it's just for other to see your work, because most of my own apps are for me personally, which might be a good thing. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor