[Tkinter-discuss] Adding <Command-Button-1> to a Listbox

Bob Greschke bob at passcal.nmt.edu
Sun Jun 7 19:52:30 CEST 2009


On May 26, 2009, at 12:23, Michael Lange wrote:

> Hi Bob,
>
> On Tue, 26 May 2009 10:31:26 -0600
> Bob Greschke <bob at passcal.nmt.edu> wrote:
>
>> I'd like to add <Command-Button-1> (i.e. use the Command key on a
>> Mac) event handling to a Listbox so that it behaves just like the
>> <Control- Button-1> "built-in" behavior (selecting/deselecting
>> individual items when the selectmode is EXTENDED).  What should the
>> bind statement call to do that?   Can it be done through something
>> like an option_add so it applies to all listboxes in an application?
>>
>
> I think
>
>    root = Tk()
>    root.bind_class('Listbox', '<Command-Button-1>',  
> root.bind_class('Listbox', '<Control-Button-1>') )
>
> should do the trick.
>
> Regards
>
> Michael


Hmmm.  This didn't seem to do anything (not even an error message).   
After some more fooling around it looks like the the Command key isn't  
acknowledged at all on my Mac (either running apps on a Sun via ssh,  
or running them directly on my Mac).  I'm running "our own" version of  
Python/Tkinter( so we don't get the Aqua-based version), and also the  
XQuartz guys' version of X11 (I messed with the keyboard preferences  
in there, but it didn't seem to do anything).  The build of our Python/ 
Tkinter may have something to do with it.  I'll check with the guys  
that make our package.  There might be some switch that needs to be  
flipped.

...but now I do see how to use .bind_class...so I still came out of  
this more dangerous than I was. :)

Thanks!

Bob



More information about the Tkinter-discuss mailing list