[Tutor] imbedding python into another program?

Andre Roberge andre.roberge at gmail.com
Fri Aug 5 04:40:03 CEST 2005

On 8/3/05, Jeff Peery <jeffpeery at yahoo.com> wrote:
> Andre, thanks for the help with this. I put it to work yesterday and it
> works perfectly. 
> was wondering if it is possible to import modules without a users having to
> type 'import whatever'. for example in my application I would like the user
> to just start operating on arrays that exist in my program. But I have to
> load both the arrays and Numeric into the python shell that I created. how
> can I do this? thanks.
> André Roberge <andre.roberge at gmail.com> wrote: 
> Jeff Peery wrote:
> > hello, is it possible to add something like the python IDLE into
> > another program, say if I wanted to simply run scripts from within a
> > wxPython program? Could someone point me to the correct reference?
> > thanks.
> > 
> Hi Jeff,
> you may want to have a look at PyCrust, PyShell and the like.
> I do something like this in my rur-ple app (on sourceforge).
> The relevant lines of code are:
> import wx.py as py
> [inside a wx.Notebook]
> win = py.shell.Shell(self.window, -1,
> self.window.AddPage(win, tr.PYTHON_INTERPRETER)
> ============

Just use "push".

Here's how I did a similar automatic import in that same program:
        win = py.shell.Shell(self.window, -1,
                            introText = tr.INTERPRETER_INTRO_TEXT)
        cmd = "from __future__ import division"   # so that 1/2 = 0.5
[irrelevant stuff deleted]



More information about the Tutor mailing list