[issue1074333] input from numeric pad always dropped when numlock off

Guilherme Polo report at bugs.python.org
Thu Apr 23 14:24:01 CEST 2009


Guilherme Polo <ggpolo at gmail.com> added the comment:

> When numlock is on, it would still
> move one line up. We could change it to fix this problem, but then we
> would be using tk::TextUpDownLine which is marked as unsupported
> (basically everything that could help us in such situations is marked as
> unsupported).

Ah yes, here is something that would do what we wanted (for "up" only):

import Tkinter

def my_up(event):
    widget = event.widget
    if event.keysym == 'KP_Up' and event.state & 16:
        widget.tk.call('tk::TextInsert', widget, event.char)
        return "break"
    pos = widget.tk.call('tk::TextUpDownLine', widget, -1)
    widget.tk.call('tk::TextSetCursor', widget, pos)

text = Tkinter.Text()
text.event_add("<<Up>>", "<Key-Up>")
text.event_add("<<Up>>", "<Key-KP_Up>")
text.bind_class("Text", "<<Up>>", my_up)
text.pack()
text.mainloop()

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1074333>
_______________________________________


More information about the Python-bugs-list mailing list