[Pythonmac-SIG] "A GUI Test Session" from Learning Python Crashes

Joseph J. Strout joe@strout.net
Sat, 2 Oct 1999 12:53:10 -0700


At 8:51 AM -0700 10/2/99, Kimlynnae Pleticha wrote:

>Hmmm.  I have to admit that this IS surprising to me.  The IDE is a great
>environment to help debug code in, but it seems to me that it should be a
>bit more stable.

Technically, this isn't an instability in the IDE -- it's a design
limitation, but not "instability" when you run code that deliberately
clobbers it (e.g., by overwriting its menus).

In my experience, it's Tk that's instable.  But I confess it's been a while
since I tried it.

>Is there a way to create Tk code so that it doesn't
>clobber the IDE menu bar when it quits?

I don't know.  Tk on the Mac is pretty nasty no matter how you look at it,
I think.

> Or is there a way to change the code in the IDE so that when running
>other Tk
>code the menu bar will not get clobbered?

Running Tk will probably always be hazardous, but I do wish you could more
easily write stand-alone Mac programs in Python with the IDE.  For this to
work, you'd have to do something like what the codewarrior IDE does: launch
the program as a separate process, and communicate with it via AppleEvents.

Seems like it wouldn't be that hard to add... we could put a "Run
Separately" option in the pop-up menu next to "Run As Main".  When checked,
it would launch a slave app, and pass it the code.  The really hard part
would be the debugger, though... hard to see how that would work.

> What methods have others used for writing Python Tk code?

You could use the BBEdit "Run As Python" plug-in with BBEdit or BBEdit
Lite.  This used to be included with MacPython; I'm not sure if it's still
there or not.

But why are you so determined to use Tk?  If your objective is to learn
Python, this is a painful way to do it.  What is it you really want to do?
If it's just to play around with graphics, I'd suggest you try PIDDLE
instead; it works perfectly well within the IDE.
(http://www.strout.net/python/piddle/)

Cheers,
-- Joe


,------------------------------------------------------------------.
|    Joseph J. Strout           Biocomputing -- The Salk Institute |
|    joe@strout.net             http://www.strout.net              |
`------------------------------------------------------------------'