Tkinter Context Menus select their first item even if you don't want them to

Robert Roy rjroy at takingcontrol.com
Wed Apr 11 21:06:43 EDT 2001


On Wed, 11 Apr 2001 11:30:49 -0700, Phlip <phlip_cpp at my-deja.com>
wrote:

>Hyp Ton:
>
>Try this code... You can right-click on the canvas to make the menu 
>pop up.
>
>http://mail.python.org/pipermail/python-list/1999-November/015485.html
>
>However, if you make the first menu item call a command that calls 
>'sys.exit(0)', merely summoning the menu with <Button-3> croaks the program.
>
>Real Context Menus display and then await a further input. This means you 
>can back out of an action instead of comiting it. Platform is LinuxPpc.
>
>My current work-around is to make the first item do nothing, but I'd 
>obviously prefer a real fix.
>


Can you post a small script that does what you are talking about? I
just tried adding sys.exit(0) to the callback in the code you
reference and it works just fine.

Bob





More information about the Python-list mailing list