I'm trying to bind the SHIFT+TAB keys, but I can't seem to get it to work. The widget I'm binding to is an Entry
widget.
I've tried binding the keys with widget.bind('<Shift_Tab>', func)
, but I get an error message saying:
File "/usr/lib64/python3.8/tkinter/init.py", line 1337, in _bind self.tk.call(what + (sequence, cmd)) _tkinter.TclError: bad event type or keysym "Shift_Tab"
Update
I'm still having a problem detecting SHIFT+TAB. Here is my test code. My OS is Linux. The tab key works, just not SHIFT+TAB. Seems like a simple problem to solve, so I must be going about it wrong?
I'm trying to tab between columns in a Treeview
that I have overlaid widgets on a row to simulate inline editing. There can be only one active widget on a line. I keep track of what column I'm in and when the user presses SHIFT+TAB or TAB, I remove the current widget and display a new widget in the corresponding column.
Here is a link to the complete project:
The project is in one file and has no imports.
The code below is my attempt and it doesn't work.
import tkinter as tk
import tkinter.ttk as ttk
class App(tk.Tk):
def __init__(self):
super().__init__()
self.rowconfigure(0, weight=1)
self.columnconfigure(0, weight=1)
self.title('Default Demo')
self.geometry('420x200')
wdg = ttk.Entry(self)
wdg.grid()
def tab(_):
print('Tab pressed.')
def shift_tab(_):
print('Shift tab pressed.')
wdg.bind('<Tab>', tab)
wdg.bind('<Control-ISO_Left_Tab>', shift_tab)
def main():
app = App()
app.mainloop()
if __name__ == '__main__':
main()
shift+tab
, then the event should be<Shift-ISO_Left_Tab>
instead of<Control-ISO_Left_Tab>
. – Lakeesha