Adding <Command-Button-1> to a Listbox
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? Thanks! Bob
Hi Bob, On Tue, 26 May 2009 10:31:26 -0600 Bob Greschke <bob@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
Thanks!
Bob
_______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org http://mail.python.org/mailman/listinfo/tkinter-discuss
On May 26, 2009, at 12:23, Michael Lange wrote:
Hi Bob,
On Tue, 26 May 2009 10:31:26 -0600 Bob Greschke <bob@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
Bob Greschke wrote:
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.
The Command key isn't supported under X11--the Control key is. Command is a Mac (Aqua) -specific keysym. -- Kevin Walzer Code by Kevin http://www.codebykevin.com
On Jun 7, 2009, at 13:25, Kevin Walzer wrote:
Bob Greschke wrote:
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.
The Command key isn't supported under X11--the Control key is. Command is a Mac (Aqua) -specific keysym. -- Kevin Walzer Code by Kevin http://www.codebykevin.com
I'll buy that. The Command key (and the Option key) are listed in Grayson as valid modifiers, so I thought they would work since the book came out way back when (2000). Thanks! Bob
participants (3)
-
Bob Greschke -
Kevin Walzer -
Michael Lange