I have some entries in tkinter. currently, I need to move the cursor to each entry and click it to select it. I am looking to do this using the arrow keys. I saw we can use bind_class to select all the Entry widgets, however, I don't know how to work around focus() to move Up/Down/Left/Right in entries.
import tkinter as tk class Data: def __init__(self): self.x = tk.IntVar() class SampleApp(tk.Tk): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.minsize(700, 700) container = tk.Frame(self) container.pack() self.data = Data() self.frames = {} for F in (PageOne, ): frame = F(container, self.data) self.frames[F] = frame frame.grid(row=0, column=0, sticky="nsew") def show_frame(self, c): frame = self.frames[c] frame.tkraise() class PageOne(tk.Frame): def __init__(self, parent, data): super().__init__(parent) self.data = data self.row_list = [] for i in range(4): self.entry_list = [] for j in range(4): self.A = tk.Entry(self) self.A.grid(row=i, column=j) self.entry_list.append(self.A) self.row_list.append(self.entry_list) self.bind_class("Entry", "<Down>", self.next_widget) self.bind_class("Entry", "<Up>", self.next_widget) self.bind_class("Entry", "<Right>", self.next_widget) self.bind_class("Entry", "<Left>", self.next_widget) def next_widget(self, event): event.widget.focus() return ("break") app = SampleApp() app.mainloop()