[Pythonmac-SIG] OptionMenu widget crashes the interpreter

Peter Funk pf@artcom-gmbh.de
Mon, 20 Mar 2000 09:45:54 +0100 (MET)


Hi Craig!

> I am wondering if there is a known bug involving using an OptionMenu
> Tkinter widget on Macs. I was just trying to make a simple GUI front end
> for a script and decided to use a pop-up menu rather than radio buttons to
> select between two options. I have used almost exactly the same code as the
> "optionmenu.py" script in the 'tkinter->guido' folders in the standard Mac
> distribution.

The sad situation is, that currently only very few mac people seem to 
use Tk and especially Tkinter.  :-(

I think that the Tk toolkit has a great potential to catch up as a very
versatile and portable gui-toolkit for three main platforms Unix/Linux,
WinXX and MacOS.  But especially on the Mac some serious work seems
to be required.  Jack Jansen, who provided the current Mac port of
Python wrote here previously, that he will be unable, to take care of
Python/Tkinter due to the lack of time.  

In the mean time I've got in contact with the developer who did the
Mac work for Tcl/Tk 8.3.0 and he feels optimistic, that it is possible 
to do serious GUIs with Tcl/Tk on the Mac and told me about several 
companys using Tcl/Tk on the mac for portable GUIs.  But of course
he can't speak for Python.

We are still in the process to catch up with the rather complicated
process to build Tcl/Tk and Python from Source on the Mac and have
still problems due to the lack of knowledge about Mac internals or
handling of Metrowerks code warrior.  There seem to be some problems
related to the automatic conversion metrowerks project files due
to the latest version of code warrior we bought.  My employee, who
is currently working on this, has taken a vacation until Tuesday,
so I can't tell you more details at the moment.  Last time I spoke
withh him, the fresh compiled Python interpreter was unable to find
the Tcl/Tk shared libs. :-(

> With both my GUI and with the script from the 'guido' folder I end up
> crashing the Python interpreter about 80 % of the time. (Sometimes
> everything runs without a hitch.) It usually results in a "type 2" error
> message.

> The "optionmenu.py" only imports Tkinter, however I don't see any reference
> to this widget in Fredrik Lundh's online "An Introdution to Tkinter". 

The option menu class is described on page 510 of John Graysons book.

Fredriks Introduction to Tkinter is still an unfinished work
in progress.  But before it was available Tkinter was very
under-documented and the only chance to get something going was to look
into the Tkinter source code, the Tk man pages and the life preserver.

The situatoin has improved much with John Graysons book, but there
are still some small uncovered areas, like for example drag'n'drop,
standard dialogs and some minor options and methods contained in
Tkinter.py.

> I did
> discover a reference to it in the new book "Python and Tkinter Programming"
> (John E. Grayson) within the PMW (Python Mega Widgets) section. However I
> don't seem to have a PMW module in my Mac distribution. 

Yes.  'Pmw' is additional Software written in pure Python.  It should
be possible to get it running on the Mac and I've also a great interest
to see this, since Pmw contains some very useful widgets, like 
Entry-fields with validators, a tabbed notebook mega widget and more.
Pmw works like a charme on Unix/Linux and on WinXX.

> Am I correct in
> assuming this is not available on the Mac platform? If so why?

You could download it from <http://www.dscpl.com.au/pmw/>
Unfortunately there is only a Unix .tar.gz file available.  If you
have a Linux-Fileserver, it it no problem, to unpack the
distribution there and get access to the folder via netatalk. 
Until now I don't know where to drop the Pmw folder on the Mac
'site-packages' works fine under Unix/Linux and WinXX.

> So what is going on with the OptionMenu widget? Is it a PWM widget or not?

Both Tkinter and Pmw contain a OptionMenu widget.  The Pmw option menu
widget however is more sophisticated and has more configuration options.

> If it is a PWM widget why does it display correctly but then crash my
> machine? Is there a better way to contruct a pop-up menu?

May be, this is due to the implementation of the Tk menubutton
widget.  But I don't know and can't help here.  It works flawlessly
on the other platforms (WinXX, Linux/Unix) so it must have to do
with the Mac port.

Regards, Peter
-- 
Peter Funk, Oldenburger Str.86, D-27777 Ganderkesee, Germany, Fax:+49 4222950260
office: +49 421 20419-0 (ArtCom GmbH, Grazer Str.8, D-28359 Bremen)