[Pythonmac-SIG] Using Tkinter with 2.1.1

Martin Miller mmiller@adobe.com
Mon, 10 Dec 2001 12:59:27 -0800


Benjamin,

What you say about the error occurring because Tkinter is being load
twice surprises me, because I have read that module "import" statements
only happen once*, the first time one is encountered for a particular
module -- which is why the built-in "reload()" function must be used. 

Perhaps it has something to do with how scripts are executed from within
the Mac Python IDE. Just van Rossum told me in a separate email (see far
below) that running Tkinter apps in the IDE is not currently supported.
I have been able to run them multiple times by dragging-and-dropping
them directly on the PythonInterpreter app.

Regards,
-Martin

*page 132-133, "Learning Python" by Lutz and Ascher.


========================================================
On Mon, 10 Dec 2001 07:54:35, Benjamin Schollnick wrote:
> 
> Martin,
> 
>         Unfornately, this problem is the same one I was having...
> 
>         It's a Tkinter issue, and as far as I know, I doubt we will
>         see a resolution to it...
> 
>         Basically, from the MacTCL list, what happening is that the
>         Tkinter library can't be loaded twice....
> 
>         The people on the MacTCL list say that this is proper behavior,
>         so the only likely fix, is that somehow MacPython is patched
>         around this behavior....
> 
>                         - Benjamin
> 
> -----Original Message-----
> From: Martin Miller [mailto:mmiller@adobe.com]
> Sent: Friday, December 07, 2001 5:12 PM
> To: pythonmac-sig
> Subject: [Pythonmac-SIG] Using Tkinter with 2.1.1
> 
> Hello, I am a Python/PythonMac newbie and have encountered a problem
> re-running scripts in the Python IDE that use the Tkinter module. They
> will work the first time I click the "run all" button (assuming there
> were no programming mistakes made ;-) but not the second time I do it.
> Instead I get the following error message:
> 
> > Menu ID 256 is already in use!Fatal Python error: Tcl/Tk panic
> 
> and the IDE locks up. All I can do at that point is option-cmd-esc and
> click the "Force Quit" button.
> 
> Here's a script that exhibits the problem:
> 
> > import Tkinter
> > widget = Tkinter.Label(None, text="Hello World!")
> > widget.pack()
> > widget.mainloop()
> 
> I tried adding a "del Tkinter" statement at the end but that did not
> help the problem.
> 
> Is there something I must do to allow such a script to be rerun without
> Quitting, restarting the IDE, and then reopening the script?
> 
> Thanks in advance.
> 
> Martin
> 
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig


===================================================
On Fri, 7 Dec 2001 23:16:48, Just van Rossum wrote:
> 
> Martin Miller wrote:
> 
> > Is there something I must do to allow such a script to be rerun without
> > Quitting, restarting the IDE, and then reopening the script?
> 
> Running Tkinter apps in the IDE is not supported. You must run your script in
> the interpreter. Maybe later in OSX, when it'll be easier to start a script as a
> new process.
> 
> Just