I am trying to display some data in table. I have tried adding a scrollbar to the table to view all the columns of table. But the scrollbar is not getting scrolled to the end of table. It just stops after scrolling a little.
Here is the code I have tried for it:
from tkinter import Tk, Toplevel, messagebox, ttk
from tkinter import *
def main():
main_window = Tk()
app = info(main_window)
main_window.mainloop()
class info:
def __init__(self, root):
self.root = root
self.root.title('First window')
# setting window to the center
self.root.geometry('1350x700+0+0') #############
self.root.resizable(width=False, height=False) #################
self.root.configure(background='white')
table = ttk.Treeview(self.root) ###########################
table1 = LabelFrame(self.root, text="Retrieved Data") ################
table1.pack(fill="both", expand="yes", padx=20, pady=10) ###################
table = ttk.Treeview(table1, height="8") #################
table['columns'] = ['Variant_ID', 'Clinical_Type', 'Allelic_ID', 'Clinical_Significance', 'Clinical_Condition',
'Allelic_Origin', 'Review_Status', 'Clinical_identifier', 'Cytogenic_Location', 'Variance',
'Type']
table.column('#0', width=120, minwidth=185)
table.column('Variant_ID', anchor=W, width=120, minwidth=185)
table.column('Clinical_Type', anchor=CENTER, width=120, minwidth=185)
table.column('Allelic_ID', anchor=CENTER, width=120, minwidth=185)
table.column('Clinical_Significance', anchor=CENTER, width=120, minwidth=185)
table.column('Clinical_Condition', anchor=CENTER, width=120, minwidth=185)
table.column('Allelic_Origin', anchor=CENTER, width=120, minwidth=185)
table.column('Review_Status', anchor=CENTER, width=120, minwidth=185)
table.column('Clinical_identifier', anchor=CENTER, width=120, minwidth=185)
table.column('Clinical_Type', anchor=CENTER, width=120, minwidth=185)
table.column('Variance', anchor=CENTER, width=120, minwidth=185)
table.column('Type', anchor=CENTER, width=120, minwidth=185)
table.heading('#0', text='Serial No.', anchor=W)
table.heading('Variant_ID', text='Variant_ID', anchor=W)
table.heading('Clinical_Type', text='Clinical_Type', anchor=CENTER)
table.heading('Allelic_ID', text='Allelic_ID', anchor=CENTER)
table.heading('Clinical_Significance', text='Clinical_Significance', anchor=CENTER)
table.heading('Clinical_Condition', text='Clinical_Condition', anchor=CENTER)
table.heading('Allelic_Origin', text='Allelic_Origin', anchor=CENTER)
table.heading('Review_Status', text='Review_Status', anchor=CENTER)
table.heading('Clinical_identifier', text='Clinical_identifier', anchor=CENTER)
table.heading('Cytogenic_Location', text='Cytogenic_Location', anchor=CENTER)
table.heading('Variance', text='Variance', anchor=CENTER)
table.heading('Type', text='Type', anchor=CENTER)
table.pack(side=LEFT) ##################
table.place(x=250, y=400) ##########################
# VERTICAL SCROLLBAR
yscrollbar = ttk.Scrollbar(table1, orient=VERTICAL, command=table.yview) #############
yscrollbar.pack(side=RIGHT, fill='y') ##################
# HORIZONTAL SCROLLBAR
xscrollbar = ttk.Scrollbar(table1, orient=HORIZONTAL, command=table.xview) ###################
xscrollbar.pack(side=BOTTOM, fill='x') #######################
table.configure(yscrollcommand=yscrollbar, xscrollcommand=xscrollbar) ##############
if __name__ == '__main__':
main()
I will be thankful if someone helps me solve this problem.