Embedding a Python with access to the app's namespace?

All:

This is probably a basic question, so please bear with me :slight_smile:

I want to embed a Python shell in a panel of my app such that it has access to all of the namespaces,
state information, etc., of my app for troubleshooting and testing behaviour in advance of having widgets
in the app that control it. What is the best way to do this?

Kindest regards,

Peter Buschman

All:

This is probably a basic question, so please bear with me :slight_smile:

I want to embed a Python shell in a panel of my app such that it has access
to all of the namespaces,
state information, etc., of my app for troubleshooting and testing
behaviour in advance of having widgets
in the app that control it. What is the best way to do this?

Use the Py module (included with the wxPython distribution).

路路路

On Wed, 27 Oct 2004 10:39:12 +0200, Peter L. Buschman <plblists@iotk.com> wrote:

Kindest regards,

Peter Buschman

Chris Mellon wrote:

All:

This is probably a basic question, so please bear with me :slight_smile:

I want to embed a Python shell in a panel of my app such that it has access
to all of the namespaces,
state information, etc., of my app for troubleshooting and testing
behaviour in advance of having widgets
in the app that control it. What is the best way to do this?

Use the Py module (included with the wxPython distribution).

And create a dictionary containing the items you want to be available in the namespace used in the shell, and pass it as the locals parameter of Shell.__init__. For example, from run.py in the demo:

         ns = {}
         ns['wx'] = wx
         ns['app'] = self
         ns['module'] = self.demoModule
         ns['frame'] = frame
...
         from wx import py
         shell = py.shell.ShellFrame(None, locals=ns)

路路路

On Wed, 27 Oct 2004 10:39:12 +0200, Peter L. Buschman <plblists@iotk.com> wrote:

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!