scrollable table tkinter

Solutions on MaxInterview for scrollable table tkinter by the best coders in the world

showing results for - "scrollable table tkinter"
Mariam
17 Nov 2016
1frame = self.frame = tk.Frame(self)
2self.frame.grid(row=1, columnspan=2, padx=2, pady=2, sticky=tk.N+tk.E+tk.S+tk.W)
3
4self.text_area = tk.Canvas(self.frame, background="black", width=400, height=500, scrollregion=(0,0,1200,800))
5self.hscroll = tk.Scrollbar(self.frame, orient=tk.HORIZONTAL, command=self.text_area.xview)
6self.vscroll = tk.Scrollbar(self.frame, orient=tk.VERTICAL, command=self.text_area.yview)
7self.text_area['xscrollcommand'] = self.hscroll.set
8self.text_area['yscrollcommand'] = self.vscroll.set
9
10self.text_area.grid(row=0, column=0, sticky=tk.N+tk.S+tk.E+tk.W)
11self.hscroll.grid(row=1, column=0, sticky=tk.E+tk.W)
12self.vscroll.grid(row=0, column=1, sticky=tk.N+tk.S)
13
14self._widgets = []
15
16for row in range(rows):
17    current_row = []
18    for column in range(columns):
19        label = tk.Label(self.text_area, text="", 
20                         borderwidth=0, width=width)
21        label.grid(row=row, column=column, sticky="nsew", padx=1, pady=1)
22        current_row.append(label)
23    self._widgets.append(current_row)