Re: [Pyobjc-dev] A python console-in-a-window
Brought to you by:
ronaldoussoren
|
From: Michael M. <mic...@gm...> - 2008-02-07 18:03:22
|
That's funny, I'm surprised I didn't see the old examples when I was looking.
Your version looks much more useful than what I put together, thanks
for sharing it!
-mike
On Feb 7, 2008 12:39 AM, Kevin A. Mitchell <ka...@ka...> wrote:
> On 2/1/08, Michael McCracken <mic...@gm...> wrote:
>
> > 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/
> >
>
> For the past few weeks I've been tinkering with the
> EmbeddedInterpreter example that comes with the PyObjC 1.4 sources,
> with pretty much the same idea of using it in a program under
> development. I've only just now gotten it packed up for public use.
>
> One trap to fall into is doing something in the embedded interpreter
> that hangs it up. The only choice then is to force quit the app.
>
> I wrote some code that uses Quartz Event Services to trap Control-C
> and cause it to interrupt the Python interpreter. There are some hooks
> to turn it on and off so that it only interrupts interactive commands,
> and not the entire program. Feel free to pick it up and use it; I put
> it under the MIT license.
>
> I've been playing with some debugging tools, including an idea for
> swizzling existing Objective-C calls and wrapping them with tracing
> code. That hasn't really worked out yet, but I'll put something in my
> blog if I get something cool put together.
>
> Blog entry:
> http://www.kamit.com/blog-entry/2008/02/07/quartz-event-services-interrupting-embedded-python
>
> Code (MIT license):
> http://www.kamit.com/hg/InterpreterKeyController
>
> --
> Kevin A. Mitchell
> http://www.kamit.com/
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Pyobjc-dev mailing list
> Pyo...@li...
> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
>
--
Michael McCracken
UCSD CSE PhD Candidate
research: http://www.cse.ucsd.edu/~mmccrack/
misc: http://michael-mccracken.net/wp/
|