[wingide-users] Setup script for python shell (or debug probe)?
support at wingware.com
Wed Sep 1 08:11:07 MDT 2010
Russell Warren wrote:
> Is there a way to create a setup script for Wing's python shell that
> is executed on each launch?
> For example, I end up typing "from pprint import pprint" many times in
> the day, and I'd like it to be always imported in the shell. Even
> better would be to have it always imported in the Debug Probe,
> although that clearly could have some contamination issues.
> If not possible, it would be a nice feature, and not just for giving
> me my sweet pprint.
The shell respects the Python standard for PYTHONSTARTUP environment
variable, so that would be a way to do this.
For the debug probe, you could write a script and bind it to a key. The
script would be something like this:
app = wingapi.gApplication
txt = "x = 1" # Really may want to read this from /path/to/startupfile.py
view = app.fSingletons.fGuiMgr.ShowPanel(config.kDebugProbePanel)
if view is None:
msg = 'Setting up debug probe' # Can be blank
dirname = app.GetStartingDirectory() # Set current directory to this
restart = False # N/A here
filename = '/path/to/startupfile.py' # Or <string> if not read from a
firstline = 0 # Not zero only if reading from line > 0 in filename
scopename = '' # Not needed here
view._Evaluate(txt, msg, dirname, restart, filename, firstline, scopename)
This reaches through the API and I'll try to add more API in the future
to avoid that.
Please let me know if that does not help.
Wingware | Python IDE
Advancing Software Development
More information about the wingide-users