Home > Software engineering >  How to bind Ctrl Tab to a function in python Tkinter?
How to bind Ctrl Tab to a function in python Tkinter?

Time:01-23

I have tried many things like :

def change_tab_right(self, event):
        print(0)
        current_tab = self.notebook.tabs().index(self.notebook.get())
        print(current_tab)
        if current_tab == self.notebook.index("end"):
            self.notebook.select(self.notebook.tabs()[0])
        else:
            self.notebook.select(self.notebook.tab(current_tab   1))

self.bind_all("<Control-Tab>", self.change_tab_right)

and all but nothing seem to work

I want to bind Ctrl tab to a function but when I click Ctrl Tab after dong the above one nothing happened. I even tried to test it with print statements but the that binding is just not calling the function.

CodePudding user response:

try to bind Ctrl Tab to your main window

self.root.bind('<Control-Tab>', self.change_tab_right)

CodePudding user response:

Edit: "<Control-Tab>" merely used for indentaion.

Try this:

self.bind_all("<Shift-Tab>", self.change_tab_right)
  • Related