I'm trying to create a py script that basically displays the data from an excel file in a tkinter window with grid layout. It create one textbox for each cell on the excel file. But when there are lots of cells, I cannot see them, because I have no scroolling implemented, and I have no idea how to implement them because the script generates 1 texbox for each cell...
here is the part of the code that generates the textboxes:
# Extracting columns from the data and creating text widget with some background color
column_names = df.columns
i=0
for j, col in enumerate(column_names):
text = Text(window, width=20, height=1, font=('Arial', 10,'bold'), bg = "#9BC2E6")
text.grid(row=i,column=j, sticky="ew")
text.tag_configure("tag_name", justify='center')
text.insert(INSERT, col)
text.tag_add("tag_name", "1.0", "end")
# adding all the other rows into the grid
for i in range(n_rows):
for j in range(n_cols):
text = Text(window, width=len(str(df.loc[i][j])), height=1, font=('Times', 8))
text.grid(row=i+1,column=j, sticky="ew")
text.tag_configure("tag_name", justify='center')
text.insert(INSERT, df.loc[i][j])
text.tag_add("tag_name", "1.0", "end")
cells[(i,j)] = text
for i in range(n_rows):
if i >= len(buttons_list):
button = Button(window, text="Copiar", bg = "#08ec9c", command=lambda row=i: copy_row(cells, n_cols, row))
button.grid(row=i+1,column=n_cols)
buttons_list.append(button)
else:
buttons_list[i].grid(row=i+1,column=n_cols)
if i >= len(remove_buttons_list):
remove_button = Button(window, text="Remover", bg = "#ac4c1e", command=lambda row=i: remove_row(i))
remove_button.grid(row=i+1,column=n_cols+1)
remove_buttons_list.append(remove_button)
else:
remove_buttons_list[i].grid(row=i+1,column=n_cols + 1)
all_data = [df.iloc[i].values.tolist() for i in range(n_rows)]
how can I scroll trough the content the code generates? (the textboxes)