Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python 2.7 tkinter - opposite of widget.tk_focusNext().focus()

With python 2.7 tkinter on linux the command e.widget.tk_focusNext().focus() work fine to focus the next widget. But how i can do the opposite? I want to focus the previous widget, how? The actual code is this:

def select(e):
    if e.keysym=="Down":
        e.widget.tk_focusNext().focus()
    elif e.keysym=="Up":
        pass
[...]
root.bind_all("<Key>",select)
like image 969
Bytez Avatar asked Jan 19 '26 18:01

Bytez


1 Answers

The function you are looking for is tk_focusPrev().

like image 72
Bryan Oakley Avatar answered Jan 22 '26 08:01

Bryan Oakley