Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #105772 > unrolled thread
| Started by | Wildman <best_lay@yahoo.com> |
|---|---|
| First post | 2016-03-26 12:10 -0500 |
| Last post | 2016-03-27 00:04 -0500 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.python
Another Key Binding Question Wildman <best_lay@yahoo.com> - 2016-03-26 12:10 -0500
Re: Another Key Binding Question MRAB <python@mrabarnett.plus.com> - 2016-03-26 17:47 +0000
Re: Another Key Binding Question Wildman <best_lay@yahoo.com> - 2016-03-27 00:04 -0500
| From | Wildman <best_lay@yahoo.com> |
|---|---|
| Date | 2016-03-26 12:10 -0500 |
| Subject | Another Key Binding Question |
| Message-ID | <g-OdncqhU4EbX2vLnZ2dnUU7-RnNnZ2d@giganews.com> |
I use some key bindings in my program. They are declared
like this:
root.bind("<Alt_L>" + "q", quit)
root.bind("<Alt_R>" + "q", quit)
root.bind("<Alt_L>" + "Q", quit)
root.bind("<Alt_R>" + "Q", quit)
The above binds both Alt keys with upper and lower case 'q'.
Is there a way to combine the statements above into one
statement?
--
<Wildman> GNU/Linux user #557453
May the Source be with you.
[toc] | [next] | [standalone]
| From | MRAB <python@mrabarnett.plus.com> |
|---|---|
| Date | 2016-03-26 17:47 +0000 |
| Message-ID | <mailman.51.1459014439.28225.python-list@python.org> |
| In reply to | #105772 |
On 2016-03-26 17:10, Wildman via Python-list wrote:
> I use some key bindings in my program. They are declared
> like this:
>
> root.bind("<Alt_L>" + "q", quit)
> root.bind("<Alt_R>" + "q", quit)
> root.bind("<Alt_L>" + "Q", quit)
> root.bind("<Alt_R>" + "Q", quit)
>
> The above binds both Alt keys with upper and lower case 'q'.
> Is there a way to combine the statements above into one
> statement?
>
Try this:
root.bind("<Alt-q>", quit)
root.bind("<Alt-Lock-Q>", quit)
The first is for either "Alt" key plus the "Q" key and Caps Lock turned off.
The second is for either "Alt" key plus the "Q" key and Caps Lock turned on.
[toc] | [prev] | [next] | [standalone]
| From | Wildman <best_lay@yahoo.com> |
|---|---|
| Date | 2016-03-27 00:04 -0500 |
| Message-ID | <pfudnbQpR7519GrLnZ2dnUU7-WvNnZ2d@giganews.com> |
| In reply to | #105777 |
On Sat, 26 Mar 2016 17:47:02 +0000, MRAB wrote:
> On 2016-03-26 17:10, Wildman via Python-list wrote:
>> I use some key bindings in my program. They are declared
>> like this:
>>
>> root.bind("<Alt_L>" + "q", quit)
>> root.bind("<Alt_R>" + "q", quit)
>> root.bind("<Alt_L>" + "Q", quit)
>> root.bind("<Alt_R>" + "Q", quit)
>>
>> The above binds both Alt keys with upper and lower case 'q'.
>> Is there a way to combine the statements above into one
>> statement?
>>
> Try this:
>
> root.bind("<Alt-q>", quit)
> root.bind("<Alt-Lock-Q>", quit)
>
> The first is for either "Alt" key plus the "Q" key and Caps Lock turned off.
Works perfectly.
> The second is for either "Alt" key plus the "Q" key and Caps Lock turned on.
Also works, however, I discovered if I leave out 'Lock' it
still works with caps on. It also works with caps off while
holding either Shift key and hitting Alt-q. I tested it with
Python 2.7 and 3.4.
Well at least I can cut the number of lines down to two per
binding like this:
root.bind("<Alt-q>", quit)
root.bind("<Alt-Q>", quit)
Once again I am in your debt. Thank you.
--
<Wildman> GNU/Linux user #557453
The cow died so I don't need your bull!
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web