[wxPython] Interactive shell / scope

Hi,
I'm using wxPython to make a small (MDI) application within which I would like to let the user optionally use an interactive shell. I'm planning to have an 'Framework' object which contains relevant information during a session (database connection, loaded objects, user rights etc). I would also like to make it possible for the user to predefine 'scripts' which can be loaded and executed from within the application.

I have two questions:

1: How would I make the framework object available to the interactive shell. I would like the user to be able to do a command in the interactive shell like:
Someobject = Framework.GetObject(SomeId)

2: Assuming that there is a menu entry for a user defined scripts, how would I 'launch' the script so that the framework object is available from within the script.

Thanks for any help.

Nikolai Kirsebom

···

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

1: How would I make the framework object available to the interactive

shell. I would like the user to be able to do a command in the interactive
shell like:

Someobject = Framework.GetObject(SomeId)

You simply need to make the object available in the global namespace used by
the interactive shell. Usually this is done by providing a dictionary of
names mapped to their respective objects. The wxPyShellWindow in the
library allows you to pass such a dictionary to the constructor.

2: Assuming that there is a menu entry for a user defined scripts, how

would I 'launch' the script so that the framework object is available from
within the script.

You can use the Python exec statement:

    exec someCode in myNamespaceDictionary

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com
http://wxPython.org Java give you jitters?
http://wxPROs.com Relax with wxPython!

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users