I am new to tkinter and I am trying to implement multiple treeviews in a frame with the scrollbar for each but I am getting single row in a treeview in each. Is there anyway to fix this issue in tkinter? Anyhelp will be appreciated!
self.future_table_frame = tk.Frame(self)
# self.future_table_frame1.place(anchor=tk.NW, relx=.0, rely=.19)
self.future_table_frame.pack(expand=True, side=tk.LEFT, fill=tk.X, pady=5)
for i in range(3):
self.dates_lbl[i] = tk.Label(self.future_table_frame, text="Date: ")
self.dates_lbl[i].pack(side=tk.TOP, anchor=tk.W)
self.dates[i] = tk.Label(self.future_table_frame)
self.dates[i].pack(side=tk.TOP, anchor=tk.W)
# Table
self.future_table[i] = ttk.Treeview(self.future_table_frame,
height=7)
# Table scrollbar
self.future_table_scroll_h[i] = tk.Scrollbar(self.future_table[i], orient=tk.HORIZONTAL)
self.future_table_scroll_h[i].pack(side=tk.BOTTOM, fill=tk.X)
self.future_table_scroll_v[i] = tk.Scrollbar(self.future_table[i], orient=tk.VERTICAL)
self.future_table_scroll_v[i].pack(side=tk.RIGHT, fill=tk.Y)
self.future_table[i].pack(side=tk.TOP, fill=tk.BOTH, pady=5)
self.future_table[i].configure(yscrollcommand=self.future_table_scroll_v[i].set,
xscrollcommand=self.future_table_scroll_h[i].set)
self.future_table_scroll_v[i].config(command=self.future_table[i].yview)
self.future_table_scroll_h[i].config(command=self.future_table[i].xview)
# Defining the columns
cash_table_columns = [f"cols{i}" for i in range(len(cash_table_columns))]
col_width = self.parent.window_width // len(cash_table_columns)
self.future_table[i]['columns'] = cash_table_columns
self.future_table[i].column("#0", width=0, stretch=tk.NO, minwidth=25)
self.future_table[i].heading("#0", text="", anchor=tk.CENTER)
for col in cash_table_columns:
self.future_table[i].column(col, anchor=tk.CENTER, stretch=tk.NO, minwidth=25, width=col_width * 2)
self.future_table[i].heading(col, text=col, anchor=tk.CENTER)
for j in range(90):
self.future_table[i].insert(parent='', index=j, iid=j, values=((j,) * len(cash_table_columns)))