Я использовал Treeview, связанный с tk.StringVar(), для фильтрации лодки, введя часть имени человека или лодки, чтобы отфильтровать список лодок для выбора.
Это работает очень хорошо.
Я пишу эту программу в Debian 12 Linux Plasma
Я хотел разместить древовидное представление на второй вкладке, чтобы отображать список лодок, выбранных в качестве записей, но когда я упаковываю это древовидное представление, блокнот не расширяется, чтобы заполнить окно.
Раскомментирование следующей строки вызывает такое поведение.
Код: Выделить всё
#tree2.pack(fill='both', expand=True)
Код: Выделить всё
import tkinter as tk
from tkinter import ttk
import csv
# root window
root = tk.Tk()
root.geometry(str('1600x900'))
# create a notebook
notebook = ttk.Notebook(root)
notebook.pack(expand=True)
# create frames for tabs
EntriesFrame = ttk.Frame(notebook, width=1600, height=880) # 20 seems to be the right amount
RaceFrame = ttk.Frame(notebook, width=1600, height=880)
# add frames to notebook as tabs
notebook.add(EntriesFrame, text='Entries')
notebook.add(RaceFrame, text='Race')
# Set up a treeview in first tab (EntriesFrame)
ColNames = ['SailNo', 'Boat', 'HelmName', 'CrewName', 'Class', 'Fleet', 'Yardstick']
tree = ttk.Treeview(EntriesFrame, columns=ColNames, show='headings')
for ColName in ColNames:
tree.heading(ColName, text=ColName)
tree.pack(fill='both', expand=True)
# a Treeview for the entries on the next tab.
tree2 = ttk.Treeview(RaceFrame, columns=ColNames, show='headings')
for ColName in ColNames:
tree2.heading(ColName, text=ColName)
#tree2.pack(fill='both', expand=True)
root.mainloop()
Подробнее здесь: https://stackoverflow.com/questions/791 ... -second-ta