Why isn’t my Tkinter scrollbar working with whole frames?

For some reason my scroll bar isn’t working. I’ve tried various methods such as using different frames and creating my own scroll function however nothing seems to work. I think it might have something to do with the packing method perhaps.

I manage to get the scrollbar working with listboxes but it’s a completely different ball game with whole frames.

from tkinter import *
import shutil
import csv
from tkinter import filedialog
import numpy as np
import matplotlib.pyplot as plt


from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg

def sign_in():
        if username_entryfield.get() == '':
            if password_entryfield.get() == '':
                print('signed in as user')
                main_page.tkraise()  # Raise the main frame
            else:
                print('incorrect password')
        else:
            print('incorrect user name')
global counter
counter = -1

def display_csv(filename):
    global counter
    rows = []
    with open(f"{filename}", 'r') as file:
        csvreader = csv.reader(file)
        header2 = next(csvreader)
        for row in csvreader:
            counter += 1
            if counter >= 3:
                data_listbox.insert(END, f'                                             {int(row[0])}                                                             {round(float(row[1]))}                                  {round(float(row[2]))}')
                
            rows.append(row)
            print(row)
            
            
def open_finder_and_copy_to_project():
    root = Tk()
    root.withdraw()  # Hide the main window

    # Open Finder to select a file
    file_path = filedialog.askopenfilename(title="Select a file")

    # Copy the selected file to your project folder
    if file_path:
        if '.csv' in file_path:
            try:
                project_folder = '/Users/Pap0010/Desktop/VISUALIZETHIS'  # Specify your project folder
                shutil.copy(file_path, project_folder)
                print("File copied to project folder successfully!")
                data_menu.tkraise()
                display_csv(file_path)
            except Exception as e:
                print(f"Error: {e}")
        else:
            print('Invalid csv file')

def clear1():
    username_entryfield.delete(0, 'end')
    password_entryfield.delete(0, 'end')

def plot():
    ax.clear()
    x = np.random.randint(0,10,10)
    y = np.random.randint(0,10,10)
    
    ax.scatter(x,y)
   

    canvas.draw()

win = Tk()
win.title('Visualize')
win.geometry('1920x1080')

display_frame = Frame(win)
display_frame.configure(width=1920,height=980,bg='#2F2F2F')
display_frame.place(x=0,y=100)

data_menu = Frame(win)
data_menu.configure(width=1920,height=980,bg='#2F2F2F')
data_menu.place(x=0,y=100)

column_header = Frame(data_menu)
column_header.configure(width=1920,height=50,bg='white')
column_header.place(x=0,y=0)

overlay_frame = Frame(win)
overlay_frame.configure(width=300,height=200,bg='white')
overlay_frame.place(x=1100,y=100)

display_frame = Frame(win)
display_frame.configure(width=1920,height=980,bg='#2F2F2F')
display_frame.place(x=0,y=100)

main_page = Frame(win)
main_page.configure(width=1920,height=1080,bg='#2F2F2F')
main_page.place(x=0,y=0)


body_frame = Frame(main_page)
body_frame.configure(width=1620,height=980,bg='green')
body_frame.place(x=300,y=0)

menu_page = Frame(main_page)
menu_page.configure(width=300,height=1080,bg='white')
menu_page.place(x=0,y=0)

header = Frame(main_page)
header.configure(width=1920,height=100,bg='grey')
header.place(x=0,y=0)


Login_page = Frame(win)
Login_page.configure(width=1920,height=1080,bg='#2F2F2F')
Login_page.place(x=0,y=0)


Heading1 = Label(Login_page,text='VISUALIZE THIS',font=("Arial", 40),fg='white')
Heading1.place(x=540,y=100)

username_entryfield = Entry(Login_page,width=15,bg='white',fg='black',font=("Arial", 40))
username_entryfield.place(x=500,y=200)

password_entryfield = Entry(Login_page,width=15,bg='white',fg='black',font=("Arial", 40),show='*')
password_entryfield.place(x=500,y=300)

enter_button = Button(Login_page, text='Sign In', font=("Arial", 20, "bold"),bg='blue',fg='white',command=sign_in)
enter_button.place(x=625,y=400)

#Header
logo = Button(header, text='', bg='white',width=3,height=3,command=lambda:main_page.tkraise())
logo.place(x=50,y=25)

profile = Button(header, text='', bg='white',width=3,height=3, command=lambda:overlay_frame.tkraise())
profile.place(x=1350,y=25)

#Overlay
logo2 = Label(overlay_frame, text='', bg='grey',width=5,height=3)
logo2.place(x=20,y=25)

overlay_name = Label(overlay_frame, text='User',fg='black',bg='white',font=("Arial", 40))
overlay_name.place(x=100,y=25)

sign_out_btn = Button(overlay_frame,text='Sign Out', highlightbackground='blue', command=lambda:(Login_page.tkraise(),clear1()))
sign_out_btn.place(x=50,y=100)

#Menu

open_file_btn = Button(menu_page,text='Open',fg='white',bg='blue',font=("Arial", 30), width=10,height=3, command=open_finder_and_copy_to_project)
open_file_btn.place(x=90,y=200)


#Body


welcome_user = Label(main_page,text='Welcome User',font=("Arial", 50, "bold"))
welcome_user.place(x=300,y=150)

##########################
#SCROLLBAR NOT WORKING D:

canvas2 = Canvas(main_page,width=1115,height=500)
canvas2.place(x=300,y=214)

yscrollbar = Scrollbar(main_page,orient='vertical',command=canvas2.yview)
yscrollbar.place(in_=canvas2, relx=1.0, relheight=1.0, bordermode="outside")

canvas2.configure(yscrollcommand=yscrollbar.set)



canvas2.bind('<Configure>',lambda e: canvas2.configure(scrollregion = canvas2.bbox('all')))


second_frame = Frame(canvas2)
canvas2.create_window((0,0),window=second_frame)

#images
#img1 = Frame(second_frame)
#img1.configure(width=600,height=300,bg='grey')
#img1.place(x=0,y=0)

#img2 = Frame(second_frame)
#img2.configure(width=300,height=300,bg='grey')
#img2.place(x=650,y=0)

#img3 = Frame(second_frame)
#img3.configure(width=600,height=300,bg='grey')
#img3.place(x=0,y=100)

#img4 = Frame(second_frame)
#img4.configure(width=300,height=300,bg='grey')
#img4.place(x=650,y=100)

#data_menu
data_scrollbar = Scrollbar(data_menu)


data_listbox =  Listbox(data_menu, yscrollcommand = data_scrollbar.set,width=100,height=20,font=("Arial", 20),fg='white',justify=LEFT)
data_scrollbar.configure( command = data_listbox.yview )

data_listbox.place(x=0,y=50)
data_scrollbar.place(in_=data_listbox, relx=1.0, relheight=1.0, bordermode="outside")

col1 = Label(column_header,text='Student Name',font=("Arial", 30, "bold"))
col1.place(x=250,y=5)

col2 = Label(column_header,text='Period 1',font=("Arial", 30, "bold"))
col2.place(x=600,y=5)

col3 = Label(column_header,text='Period 2',font=("Arial", 30, "bold"))
col3.place(x=850,y=5)


display_btn = Button(data_menu,text='Display',font=("Arial", 40, "bold"),command=lambda:(plot(),display_frame.tkraise()))
display_btn.place(x=600,y=550)

#Display Frame
fig, ax = plt.subplots()

canvas = FigureCanvasTkAgg(fig,master=display_frame)
canvas.get_tk_widget().place(x=0,y=0)


win.mainloop()

1

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