<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#330099">
<font face="Verdana">Thanks for your comment.<br>
<br>
The purpose of the application is to automate the manipulation of large
numbers of files. For automation I want to be able to have scripts that
I can use for various purposes. <br>
<br>
On input, cmd.py handles calling "do_...." methods for known commands;
for the rest I want to "exec" the lines with my own dictionary. This
allows me to use python statements, so I can do things like
concatenating variables to form directory names, and so on. I'd like to
be able to use any python statement, including "x=raw_input('>')",
but this currently brings everything to a halt.<br>
<br>
One thing this app does is execute processes using wxPythons wx.Process
object and wx.Execute function. wxPython makes it easy to redirect
stdin and stdout. I'm trying to do a similar thing for individual
python statements. I'm not sure that makes sense.<br>
<br>
I hope that's clear. <br>
<br>
Rick<br>
</font><br>
<br>
David C Ullrich wrote:
<blockquote cite="mid:GsqdnRDOB6ob_x3XRVn_vwA@giganews.com" type="cite">
  <pre wrap="">What you're trying to do and what's not working isn't 
entirely clear to me.

But if I had a wxPython application and I wanted to
execute user input (note the _if_) I'd just pop up a window
(I forget how "ShowModal" is spelled in wx right now)
with a text box and an Execute button and a Cancel
button - if the user hits the Execute button I'd
attempt to execute what he'd typed in the box.

There are reasons you want to be very careful about
this...

On Mon, 10 Aug 2009 13:44:17 -0400, Rick King wrote:

  </pre>
  <blockquote type="cite">
    <pre wrap="">I have a cmd.py-derived program (with a wxPython GUI) and want to
execute python statements for lines that are not my own special
commands.

So basically it's either:

    def do_somecommand(self,arg):
        ...

or

    def default(self,arg):
        exec arg in globals(),self.cmdlocals

(where cmdlocals is a my local dictionary)

in default() I'd like to be able to execute any python statement
including something like

    "x = raw_input('>')"

when I do this though it goes to the command window and so any user of
the program would be confused, which also means I have to have a command
window.

If I add this:

    self.stdin = self.edt_console_input   (where self.edt_console_input
is a wxPython text control)

it just gets an EOF right away.

Is there any way to do what I want to do? This might be better posted on
the wxpython list.

Thanks for any help!

Rick King
Southfield MI
    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
</blockquote>
</body>
</html>