Skip to content Skip to sidebar Skip to footer

Getting Tab Key To Go To Next Field With Tkinter Text (instead Of Indent)

I have searched and spent about literally two hours trying to solve this myself, but my efforts have failed me. My goal is to type a message in the text box, press tab to go to the

Solution 1:

Shift-tab is used for reverse-traversal.

I think the following page will be of use to you: http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/focus.html

From this page, there is one paragraph that may assist you,

To sum up: to set up the focus traversal order of your widgets, create them in that order. Remove widgets from the traversal order by setting their takefocus options to 0, and for those whose default takefocus option is 0, set it to 1 if you want to add them to the order.

*Edit: Looks like a duplicate of Change the focus from one Text widget to another

**Edit2: So... as taken from the stackoverflow post above, the following will do exactly what you request:

def focus_next_widget(event):
    event.widget.tk_focusNext().focus()
    return("break")

window = Tk()
window.title("What's Your Message?")
window.configure(background="black")
Label (window, text="Type Your Message:\n", bg="Black", fg="white", font="none 25 bold").pack(anchor=N)

e = Text(window, width=75, height=10)
e.bind("<Tab>", focus_next_widget)

Post a Comment for "Getting Tab Key To Go To Next Field With Tkinter Text (instead Of Indent)"