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

Hyp Ton:

Try this code... You can right-click on the canvas to make the menu
pop up.

http://www.*-*-*.com/

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.

--

============== http://www.*-*-*.com/ ==============
  --  All sensors report Patti having a very good time  --



Mon, 29 Sep 2003 02:30:49 GMT  
 Tkinter Context Menus select their first item even if you don't want them to


Quote:
>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



Mon, 29 Sep 2003 09:06:43 GMT  
 Tkinter Context Menus select their first item even if you don't want them to
Proclaimed Phlip from the mountaintops:

Quote:
> 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.

Thanks to someone for the request that I provide the offending source, but
I'm on another project right now.

I suspect the issue boils down to with my code the geometry math puts the
menu such that the mouse is over the first item when the tip appears. Then
mouse-up selects the item.

The fix is to get the geometry right, putting the menu a pixel southwest of
the mouse, and maybe to trigger the context menu on mouse-up instead of
mouse-down.

--

============== http://phlip.webjump.com ==============
  --  I don't want to work. I want to surf on de 'net all day.
      I don't want to play. I just want to surf on de 'net all day.  --



Tue, 30 Sep 2003 14:16:28 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ContexT. Menu ITEM NUMBER

2. context menu for listbox items?

3. ODBC - Don't even think about it!

4. selecting a menu item

5. A VI opens when executing, even if I don't want to

6. Ruby/Tk :: Opening a new window when selecting menu items

7. Return Index Number For Selected Menu Item

8. Modifying menu item selected by means of an event

9. Selecting an item within a menu

10. Q: Internally selecting a menu item - HELP!

11. Tkinter checkbutton menu item,

12. Tkinter: a widget within a menu(item)

 

 
Powered by phpBB® Forum Software