python editor and shell question

hello, I’m using the python editor from py.editor.Editor and the python shell from py.shell.Shell in a wxpython application. I want to run a script written in the editor in from the shell. is there a good way to do this? right now I save the editor text to a text file then run the saved file from the shell.

if this is the best way to do it, then I have a problem because II get an error indicating that the first argument must be a editor instance and it got an editor object.

here;s how I run the text:

pyEditor = py.editor.EditWindow(py.editor.Editor, parent, -1))

pyShell = py.shell.Shell(oarebtm -1, introText=none)

nyText = py.editor.Editor.getText(self.pyEditor)

fileHandle = file(‘myTexty.py’, ‘w’)

fileHandle.write(myText)

fileHandle.close()

pyWindowCmd(‘myText.py’, pyShell)

what am I mssing here?

thanks!

Jeff

Hello Jeff,

I don't understand you exactly;
where is the problem?

What is pyWindowCmd?
Is it your own written function?

taken from shell:
    def execPythonStartupScript(self, pythonstartupScript):
        """Execute the user's PYTHONSTARTUP script if they have one."""
        if pythonstartupScript and os.path.isfile(pythonstartupScript):
            text = 'Startup script executed: ' + pythonstartupScript
            self.push('print %r; execfile(%r)' % (text, pythonstartupScript))

so you could call somehow:
pyShell.push ('execfile(%r)' % pyShell)
or simply pyShell.push(nyText)

···

On Wed, 17 Aug 2005 20:33:41 -0700 (PDT), Jeff Peery <jeffpeery@yahoo.com> wrote:

hello, I'm using the python editor from py.editor.Editor and the python shell from py.shell.Shell in a wxpython application. I want to run a script written in the editor in from the shell. is there a good way to do this? right now I save the editor text to a text file then run the saved file from the shell.

if this is the best way to do it, then I have a problem because II get an error indicating that the first argument must be a editor instance and it got an editor object.

here;s how I run the text:

pyEditor = py.editor.EditWindow(py.editor.Editor, parent, -1))
pyShell = py.shell.Shell(oarebtm -1, introText=none)

nyText = py.editor.Editor.getText(self.pyEditor)

fileHandle = file('myTexty.py', 'w')

fileHandle.write(myText)

fileHandle.close()

pyWindowCmd('myText.py', pyShell)

what am I mssing here?
thanks!

Jeff

--
Franz Steinhaeusler

oh yes, I apologize. the pyWindowCmd is my own function that uses shell.push.

the problem is with getText(). I get an error that says (if I remember correctly) that the first arguement needs an editor instance not an object. what should the editor.getText arguement be?

also is this the best method for just executing a script from an editor? thanks.

···

Franz Steinhäusler franz.steinhaeusler@gmx.at wrote:

On Wed, 17 Aug 2005 20:33:41 -0700 (PDT), Jeff Peery wrote:

hello, I’m using the python editor from py.editor.Editor and the python shell from py.shell.Shell in a wxpython application. I want to run a script written in the editor in from the shell. is there a good way to do this? right now I save the editor text to a text file then run the saved file from the shell.

if this is the best way to do it, then I have a problem because II get an error indicating that the first argument must be a editor instance and it got an editor object.

here;s how I run the text:

pyEditor = py.editor.EditWindow(py.editor.Editor, parent, -1))
pyShell = py.shell.Shell(oarebtm -1, introText=none)

nyText = py.editor.Editor.getText(self.pyEditor)

fileHandle = file(‘myTexty.py’, ‘w’)

fileHandle.write(myText)

fileHandle.close()

pyWindowCmd(‘myText.py’, pyShell)

what am I mssing here?
thanks!

Jeff

Hello Jeff,

I don’t understand you exactly;
where is the problem?

What is pyWindowCmd?
Is it your own written function?

taken from shell:
def execPythonStartupScript(self, pythonstartupScript):
“”“Execute the user’s PYTHONSTARTUP script if they have one.”“”
if pythonstartupScript and os.path.isfile(pythonstartupScript):
text = 'Startup script executed: ’ + pythonstartupScript
self.push(‘print %r; execfile(%r)’ % (text, pythonstartupScript))

so you could call somehow:
pyShell.push (‘execfile(%r)’ % pyShell)
or simply pyShell.push(nyText)


Franz Steinhaeusler


To unsubscribe, e-mail:
wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

pyEditor = py.editor.EditWindow(py.editor.Editor, parent, -1))

here you pass a class (py.editor.Editor) instead of an object (for example an edit window)

nyText = py.editor.Editor.getText(self.pyEditor)
here it should be enough: nyText = pyEditor.GetText()
because pyEditor is an instance of StyledTextCtrl.

pyEditor
<wx.py.editor.EditWindow; proxy of C++ wxStyledTextCtrl instance at _881db001_p_wxStyledTextCtrl>

···

On Wed, 17 Aug 2005 20:33:41 -0700 (PDT), Jeff Peery <jeffpeery@yahoo.com> wrote:

pyEditor = py.editor.EditWindow(py.editor.Editor, parent, -1))
pyShell = py.shell.Shell(oarebtm -1, introText=none)

nyText = py.editor.Editor.getText(self.pyEditor)

--
Franz Steinhaeusler