Trying to add a H scroll bar to a table in python

I am trying to view my database in python but I cant seem to implement the scrollbar correctly. Chatgpt cant seem to either. I tried to use canvas but It just ruined the entire thing.

since im supposed to yap before i can post i can say that i am doing this because the gui guy in my project flaked out suddenly and left me in a rut. bad no???

import tkinter as tk
from tkinter import ttk
import sqlite3

# Function definitions for clubs, games, competitions, appearances, players, game events, game lineups, and player valuations
root = tk.Tk()
root.title('Soccer App')

conn = sqlite3.connect('D:\D2\PythonDB.db')
c = conn.cursor()

# Create a Notebook widget to switch between different functionalities
notebook = ttk.Notebook(root)
notebook.pack(fill='both', expand=True)

# Create frames for each tab
clubs_frame = ttk.Frame(notebook)
games_frame = ttk.Frame(notebook)
competitions_frame = ttk.Frame(notebook)
appearances_frame = ttk.Frame(notebook)
data_visualization_frame = ttk.Frame(notebook)  # Frame for data visualization

# Add each frame to the notebook
notebook.add(clubs_frame, text='Clubs')
notebook.add(games_frame, text='Games')
notebook.add(competitions_frame, text='Competitions')
notebook.add(appearances_frame, text='Appearances')
notebook.add(data_visualization_frame, text='Data Visualization')  # Data Visualization Tab

# Function for clubs
# Function for clubs
def def_clubs():
    global c
    # Create the main frame for clubs
    main_frame = ttk.Frame(clubs_frame, padding='10')
    main_frame.grid(row=0, column=0, sticky='nsew')

    # Create the form for adding clubs
    club_id_var = tk.IntVar()
    club_name_var = tk.StringVar()
    club_code_var = tk.StringVar()
    domestic_competition_id_var = tk.IntVar()  # Variable for domestic competition ID
    total_market_value_var = tk.DoubleVar()  # Variable for total market value
    squad_size_var = tk.IntVar()  # Variable for squad size
    average_age_var = tk.DoubleVar()  # Variable for average age
    foreigners_number_var = tk.IntVar()  # Variable for number of foreigners
    foreigners_percentage_var = tk.DoubleVar()  # Variable for percentage of foreigners
    national_team_players_var = tk.IntVar()  # Variable for number of national team players
    stadium_name_var = tk.StringVar()  # Variable for stadium name
    stadium_seats_var = tk.IntVar()  # Variable for stadium seats
    net_transfer_record_var = tk.DoubleVar()  # Variable for net transfer record
    coach_name_var = tk.StringVar()  # Variable for coach name
    last_season_var = tk.StringVar()  # Variable for last season
    filename_var = tk.StringVar()  # Variable for filename
    url_var = tk.StringVar()  # Variable for URL
    
    tk.Label(main_frame, text='Club ID:').pack()

    tk.Entry(main_frame, textvariable=club_id_var, width=30).pack()


    tk.Label(main_frame, text='Club Name:').pack()

    tk.Entry(main_frame, textvariable=club_name_var, width=30).pack()


    tk.Label(main_frame, text='Club Code:').pack()

    tk.Entry(main_frame, textvariable=club_code_var, width=30).pack()


    tk.Label(main_frame, text='Domestic Competition ID:').pack()

    tk.Entry(main_frame, textvariable=domestic_competition_id_var).pack()

    tk.Label(main_frame, text='Total Market Value:').pack()

    tk.Label(main_frame, text='Squad Size:').pack()
    tk.Entry(main_frame, textvariable=squad_size_var).pack()
    tk.Label(main_frame, text='Average Age:').pack()
    tk.Entry(main_frame, textvariable=average_age_var).pack()
    tk.Label(main_frame, text='Foreigners Number:').pack()
    tk.Entry(main_frame, textvariable=foreigners_number_var).pack()
    tk.Label(main_frame, text='Foreigners Percentage:').pack()
    tk.Entry(main_frame, textvariable=foreigners_percentage_var).pack()
    tk.Label(main_frame, text='National Team Players:').pack()
    tk.Entry(main_frame, textvariable=national_team_players_var).pack()
    tk.Label(main_frame, text='Stadium Name:').pack()
    tk.Entry(main_frame, textvariable=stadium_name_var).pack()
    tk.Label(main_frame, text='Stadium Seats:').pack()
    tk.Entry(main_frame, textvariable=stadium_seats_var).pack()
    tk.Label(main_frame, text='Net Transfer Record:').pack()
    tk.Entry(main_frame, textvariable=net_transfer_record_var).pack()
    tk.Label(main_frame, text='Coach Name:').pack()
    tk.Entry(main_frame, textvariable=coach_name_var).pack()
    tk.Label(main_frame, text='Last Season:').pack()
    tk.Entry(main_frame, textvariable=last_season_var).pack()
    tk.Label(main_frame, text='Filename:').pack()
    tk.Entry(main_frame, textvariable=filename_var).pack()
    tk.Label(main_frame, text='URL:').pack()
    tk.Entry(main_frame, textvariable=url_var).pack()


    # Create a function to handle the form submission
    def submit_club():
        club_id = club_id_var.get()
        club_name = club_name_var.get()
        club_code = club_code_var.get()
        domestic_competition_id = domestic_competition_id_var.get()
        total_market_value = total_market_value_var.get()
        squad_size = squad_size_var.get()
        average_age = average_age_var.get()
        foreigners_number = foreigners_number_var.get()
        foreigners_percentage = foreigners_percentage_var.get()
        national_team_players = national_team_players_var.get()
        stadium_name = stadium_name_var.get()
        stadium_seats = stadium_seats_var.get()
        net_transfer_record = net_transfer_record_var.get()
        coach_name = coach_name_var.get()
        last_season = last_season_var.get()
        filename = filename_var.get()
        url = url_var.get()

        c.execute('''INSERT INTO clubs VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
                  (club_id, club_name, club_code, domestic_competition_id, total_market_value, squad_size,
                   average_age, foreigners_number, foreigners_percentage, national_team_players, stadium_name,
                   stadium_seats, net_transfer_record, coach_name, last_season, filename, url))
        conn.commit()

        # Clear the form fields
        club_id_var.set('')
        club_name_var.set('')
        club_code_var.set('')
        domestic_competition_id_var.set('')
        total_market_value_var.set('')
        squad_size_var.set('')
        average_age_var.set('')
        foreigners_number_var.set('')
        foreigners_percentage_var.set('')
        national_team_players_var.set('')
        stadium_name_var.set('')
        stadium_seats_var.set('')
        net_transfer_record_var.set('')
        coach_name_var.set('')
        last_season_var.set('')
        filename_var.set('')
        url_var.set('')

        # Update the Treeview widget
        update_clubs()

    # Create the submit button for the form
    submit_button = ttk.Button(main_frame, text='Submit', command=submit_club)
    submit_button.pack(pady=(10, 0))

    # Create the Treeview widget for displaying clubs
    clubs_tree = ttk.Treeview(main_frame, columns=('club_id', 'club_name', 'club_code', 'domestic_competition_id',
                                                    'total_market_value', 'squad_size', 'average_age',
                                                    'foreigners_number', 'foreigners_percentage',
                                                    'national_team_players', 'stadium_name', 'stadium_seats',
                                                    'net_transfer_record', 'coach_name', 'last_season', 'filename',
                                                    'url'))
                         
    clubs_tree.heading('#0', text='Club ID')
    clubs_tree.heading('club_id', text='Club ID')
    clubs_tree.heading('club_name', text='Club Name')
    clubs_tree.heading('club_code', text='Club Code')
    clubs_tree.heading('domestic_competition_id', text='Domestic Competition ID')
    clubs_tree.heading('total_market_value', text='Total Market Value')
    clubs_tree.heading('squad_size', text='Squad Size')
    clubs_tree.heading('average_age', text='Average Age')
    clubs_tree.heading('foreigners_number', text='Foreigners Number')
    clubs_tree.heading('foreigners_percentage', text='Foreigners Percentage')
    clubs_tree.heading('national_team_players', text='National Team Players')
    clubs_tree.heading('stadium_name', text='Stadium Name')
    clubs_tree.heading('stadium_seats', text='Stadium Seats')
    clubs_tree.heading('net_transfer_record', text='Net Transfer Record')
    clubs_tree.heading('coach_name', text='Coach Name')
    clubs_tree.heading('last_season', text='Last Season')
    clubs_tree.heading('filename', text='Filename')
    clubs_tree.heading('url', text='URL')
    clubs_tree.pack(pady=(10, 0), fill='both', expand=True)


    #Configure the Treeview to use the horizontal scrollbar
    clubs_tree.configure(xscrollcommand=scrollbar_x.set)

    # Pack the Treeview widget
    clubs_tree.pack(fill='both', expand=True)
# Create a function to handle the remove button
    def remove_club():
        selected_club = clubs_tree.selection()
        if selected_club:
            club_id = clubs_tree.item(selected_club)['values'][0]
            c.execute('DELETE FROM clubs WHERE club_id=?', (club_id,))
            conn.commit()
            update_clubs()

    # Create a function to update the Treeview widget with the clubs from the database
    def update_clubs():
        clubs_tree.delete(*clubs_tree.get_children())
        c.execute('SELECT * FROM clubs')
        clubs = c.fetchall()
        for club in clubs:
            clubs_tree.insert('', 'end', values=club)

    # Create the remove button
    remove_button = ttk.Button(main_frame, text='Remove', command=remove_club)
    remove_button.pack(pady=(10, 0))

    # Update the Treeview widget with the clubs from the database
    update_clubs()

    # Labels and Entry fields for parameters
    table_label = ttk.Label(data_visualization_frame, text="Table:")
    table_label.grid(row=0, column=0, padx=10, pady=10)
    table_entry = ttk.Entry(data_visualization_frame)
    table_entry.grid(row=0, column=1, padx=10, pady=10)

    column1_label = ttk.Label(data_visualization_frame, text="Column for labels:")
    column1_label.grid(row=1, column=0, padx=10, pady=10)
    column1_entry = ttk.Entry(data_visualization_frame)
    column1_entry.grid(row=1, column=1, padx=10, pady=10)

    column2_label = ttk.Label(data_visualization_frame, text="Column for values:")
    column2_label.grid(row=2, column=0, padx=10, pady=10)
    column2_entry = ttk.Entry(data_visualization_frame)
    column2_entry.grid(row=2, column=1, padx=10, pady=10)

    # Button to plot pie chart
    pie_button = ttk.Button(data_visualization_frame, text='Pie Chart', command=plot_pie_chart)
    pie_button.grid(row=3, column=0, columnspan=2, padx=10, pady=10)
    bar_button = ttk.Button(data_visualization_frame, text='Bar Chart', command=plot_bar_chart)
    bar_button.grid(row=4, column=0, columnspan=2, padx=10, pady=10)
    scatter_button = ttk.Button(data_visualization_frame, text='Scatter Plot', command=plot_scatter_chart)
    scatter_button.grid(row=5, column=0, columnspan=2, padx=10, pady=10)
    
def_clubs()
def_games()
def_competitions()
handle_appearance_table()
handle_players_table()
def_game_events()
def_game_lineups()
player_valuations()
data_visualization()
# Start the Tkinter event loop
root.mainloop()

#rest of code is unimportant#

I just want help y’all

New contributor

John Smith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật