classification
Title: tkinter keysym_num value is incorrect
Type: Stage: resolved
Components: Versions:
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: serhiy.storchaka, spacether
Priority: normal Keywords:

Created on 2020-12-20 21:22 by spacether, last changed 2020-12-20 21:53 by spacether. This issue is now closed.

Messages (3)
msg383458 - (view) Author: Justin (spacether) Date: 2020-12-20 21:22
Hi there.
On my MacOS 10.14.16 laptop with a qwerty keyboard I was testing tkinter keyboard listening for an azerty keyboard layout by switching the layout to `French - PC`
When I press qwerty keys Shift + \ I expect to see 'μ' printed.
When looking at the tkinter events for that key press we see:
```
down {'keysym': 'Shift_L', 'keysym_num': 65505, 'keycode': 131072, 'char': ''}
down {'keysym': 'tslash', 'keysym_num': 956, 'keycode': 956, 'char': 'μ'}
up {'keysym': 'asterisk', 'keysym_num': 42, 'keycode': 2753468, 'char': 'μ'}
up {'keysym': 'Shift_L', 'keysym_num': 65505, 'keycode': 131072, 'char': ''}
```
So the char value is correct but the keysym_num is not the expected 181 for mu.
Comparing this to pressing Shift + / to generate the section symbol (§) we see:
```
down {'keysym': 'Shift_L', 'keysym_num': 65505, 'keycode': 131072, 'char': ''}
down {'keysym': 'section', 'keysym_num': 167, 'keycode': 167, 'char': '§'}
up {'keysym': 'section', 'keysym_num': 167, 'keycode': 2883751, 'char': '§'}
up {'keysym': 'Shift_L', 'keysym_num': 65505, 'keycode': 131072, 'char': ''}
```
Which produces the expected keysym_num of 167.

TLDR: the kysym_num value when writing the mu character is incorrect. It should be 181 and logging shows values of 956 and 42. Can this be fixed?

Here is the keyboard listener program which can be used for verification:
```
from tkinter import *

params = ['keysym', 'keysym_num', 'keycode', 'char']

def keyup(e):
    d = {p: getattr(e, p) for p in params}
    print('up', d)
    # print('up', e.__dict__)
def keydown(e):
    d = {p: getattr(e, p) for p in params}
    print('down', d)
    # print('down', e.__dict__)
    pass

root = Tk()
frame = Frame(root, width=100, height=100)
frame.bind("<KeyPress>", keydown)
frame.bind("<KeyRelease>", keyup)
frame.pack()
frame.focus_set()
root.mainloop()
```
Note: my python version was installed from python.org and is:
```
Python 3.9.1 (v3.9.1:1e5d33e9b9, Dec  7 2020, 12:44:01) 
[Clang 12.0.0 (clang-1200.0.32.27)] on darwin
```
msg383461 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-12-20 21:33
Tkinter is just a wrapper around Tcl/Tk. Please report a bug in Tk on the corresponding bug tracker.

https://wiki.tcl-lang.org/page/How+do+I+report+a+bug+in+Tcl%2C+Tk%2C+...
msg383463 - (view) Author: Justin (spacether) Date: 2020-12-20 21:53
TK bug ticket has been created at https://core.tcl-lang.org/tk/tktview/ffe6925b916caac02acae53f745e95dd1c557019
History
Date User Action Args
2020-12-20 21:53:52spacethersetmessages: + msg383463
2020-12-20 21:33:13serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg383461

resolution: third party
stage: resolved
2020-12-20 21:22:53spacethercreate