Я пытаюсь добавить полосу прокрутки, которая синхронизируется c с именем игрока, позицией, ростом, весом и колледжами, но я могу только прокручивать таблицу игроков ( древовидная структура ).
Может ли кто-нибудь помочь мне и предоставить мне код для проблемы полосы прокрутки?
вот код:
from tkinter import *
from tkinter import ttk
root = Tk()
root.geometry("850x500")
none = []
player = open('NBA n ABA players.txt', 'r', encoding='utf-8')
content = player.readlines()
players = [s.strip('\n') for s in content]
pos = open('pos.txt', 'r', encoding='utf-8')
content2 = pos.readlines()
positions = [s.strip('\n') for s in content2]
ht = open('ht.txt', 'r', encoding='utf-8')
content3 = ht.readlines()
hts = [s.strip('\n') for s in content3]
wt = open('wt.txt', 'r', encoding='utf-8')
content4 = wt.readlines()
wts = [s.strip('\n') for s in content4]
college = open('colleges.txt', 'r', encoding='utf-8')
content5 = college.readlines()
colleges = [s.strip('\n') for s in content5]
frame = Frame(root)
frame.pack()
tree = ttk.Treeview(frame, columns=1, height=len(players), show="headings")
tree_pos = ttk.Treeview(frame, columns=1, height=len(positions), show="headings")
tree_ht = ttk.Treeview(frame, columns=1, height=len(hts), show="headings")
tree_wt = ttk.Treeview(frame, columns=1, height=len(wts), show="headings")
tree_col = ttk.Treeview(frame, columns=1, height=len(colleges), show="headings")
tree.pack(side='left')
tree_pos.pack(side='left')
tree_ht.pack(side='left')
tree_wt.pack(side='left')
tree_col.pack(side='left')
tree.heading(1, text="NBA / ABA PLAYERS")
tree_pos.heading(1, text="Position")
tree_ht.heading(1, text="Height")
tree_wt.heading(1, text="Weight")
tree_col.heading(1, text="Colleges")
tree.column(1, width=140)
tree_pos.column(1, width=140)
tree_ht.column(1, width=140)
tree_wt.column(1, width=140)
tree_col.column(1, width=240)
scroll = ttk.Scrollbar(frame, orient="vertical")
scroll.pack(side='right', fill='y')
for x in players:
tree.insert('', 'end', values=[x])
for x in positions:
tree_pos.insert('', 'end', values=[x])
for x in hts:
tree_ht.insert('', 'end', values=[x])
for x in wts:
tree_wt.insert('', 'end', values=[x])
for x in colleges:
tree_col.insert('', 'end', values=[x])
root.mainloop()
ссылка на скриншот окна вывода здесь: https://i.stack.imgur.com/kXYMv.png