Alex Katarani
Alex Katarani

Reputation: 21

Tkinter how to disable shortcuts in text widgets?

I'm creating an app using Tkinter and a text widget, and I discover interesting but unwelcome shortcuts events.


from tkinter import Text, Tk

root = Tk()
text = Text(root)
text.pack()
root.mainloop()
    

#Ctrl+o- insert a new line,
#Ctrl+i- tab,
#Ctrl+e- put the cursor at the end of the line,
#Ctrl+a- put the cursor at the beginning of the line

My question is where can I find more info about these shortcuts, and how can I disable them?

Upvotes: 0

Views: 107

Answers (1)

Tranbi
Tranbi

Reputation: 12701

You can bind the combinations you want to deactivate to a function that returns "break". For instance:

from tkinter import Text, Tk

def do_nothing(e):
    return "break"

root = Tk()
text = Text(root)
text.bind("<Control-I>", do_nothing)
text.pack()
root.mainloop()

You can find default bindings in the doc under the Bindings section.

Upvotes: 3

Related Questions