[Pyobjc-dev] A python console-in-a-window
Brought to you by:
ronaldoussoren
|
From: Michael M. <mic...@gm...> - 2008-02-01 06:46:15
|
Hi, I got the urge to embed a python console in my app so I could poke
around in it while it was running.
I didn't find an example of doing just that when I looked, so I
thought I'd put one together and share it.
I used it like this, tying it to a menu item:
@IBAction
def showPyConsole_(self, sender):
if self.pyconsole is None:
locals = {'m': self}
welcome = "Welcome to the Console.\nThe main window
controller is called 'm'."
self.pyconsole =
PyConsole.PyConsole.alloc().initWithLocals_welcomeMsg_(locals,
welcome)
self.pyconsole.showWindow_(self)
It pops up a window running a REPL that's pretty close to the python
interactive interpreter.
The code and xib are here: http://michael-mccracken.net/software/PyConsole.zip
I've licensed it as BSD.
I'd be curious to hear if anyone else finds it useful.
(Patches, suggestions, etc are nice too.)
Cheers,
-mike
--
Michael McCracken
misc: http://michael-mccracken.net/wp/
|