Title: how to add scrollbar to specific elements in tkinter
Tags: python,class,tkinter,scrollbar,customtkinter

Question: i'm making an app where you can add in folders, the problem is that the 'icons' to show the folders go offscreen. i tried to implement a scrollbar myself but after a few hours found myself unable to, could you tell me how to add it in? i'm using tkinter/customTkinter to make the app.
here is the code:
import threading 
from subprocess import PIPE, Popen 
import tkinter 
import customtkinter 
from tkinter import filedialog 
from PIL import Image, ImageTk 
import shutil 
import os 
from PIL import ImageTk, Image 

customtkinter.set_appearance_mode("dark") # Modes: system (default), light, dark customtkinter.set_default_color_theme("dark-blue") # Themes: blue (default), dark-blue, green





class ShimejiBlock:
    def __init__(self, root, folder_name: str):

        self.folder_path = './Shimeji/'+folder_name+'/'
        self.jar_file = [f for f in os.listdir(self.folder_path) if f.endswith('.jar')][0]

        self.ico_file = [f for f in os.listdir('./Shimeji/'+folder_name) if f.endswith('.ico')][0]
        self.folder_name = folder_name
        self.image = './Shimeji/'+folder_name

        frame = customtkinter.CTkFrame(root, fg_color="#141414", width=250,height=100)
        frame.place(x=120, y=50 + len(ShimejiList) * 120)


        button = customtkinter.CTkButton(root,width=250,height=100,text=folder_name, command=self.openShimeji,bg_color='gray8',fg_color='gray8',hover_color='gray8',anchor='e',border_spacing=25)
        button.place(x=120, y=50 + len(ShimejiList) * 120)


        self.image = Image.open('./Shimeji/'+folder_name+'/'+self.ico_file).resize((100,100))
        self.image = ImageTk.PhotoImage(self.image)


        pixel = len(ShimejiList) * 148

        canvas = tkinter.Canvas(root,height=100,width=100,bg='gray8')
        canvas.place(x=160, y=75 + pixel)
        canvas.create_image(0,0,anchor='nw',image=self.image)


        #pixel2 = len(ShimejiList) * 120

        #Name = customtkinter.CTkLabel(root, text=folder_name,fg_color='gray8', bg_color='gray8')
        #Name.place(x=220, y=86 + pixel2)


    def openShimeji(self):
        OpenShimeji(self.folder_name,self.jar_file)

        


        








def UpdateShimeji(root, FolderName): 
    ShimejiBlock(root, FolderName)


def open_jar_file(folder_name, jar_file): 
    os.system(f'cd "./Shimeji/{folder_name}" & {jar_file}')

def FileExplorer(): 
    folder_path = filedialog.askdirectory() 
    folder_name = folder_path[folder_path.rfind('/') + 1:] 
    if(os.path.exists('./Shimeji/' + folder_name) != True):
        shutil.copytree(folder_path, './Shimeji/' + folder_name) 
        UpdateShimeji(folder_name)

def OpenShimeji(Name,jar):
    jar_thread = threading.Thread(target=open_jar_file, args=(Name, jar))
    jar_thread.start()



def DetectShimeji():
    ShimejiFolderList = os.listdir('./Shimeji')
    if(ShimejiFolderList != []):
        for i in ShimejiFolderList:
            if( [f for f in os.listdir('./Shimeji/'+i+'/') if f.endswith('.jar')] != []):
                ShimejiList.append(ShimejiBlock(app, i))
            
                

            




ShimejiFolderList = []
ShimejiList = []
app = customtkinter.CTk() 
app.geometry("500x440") 
app.minsize(width=500, height=440) 
app.maxsize(width=500, height=440) 
app.title("Shimeji Tool") 
ico = Image.open('ico.png') 
photo = ImageTk.PhotoImage(ico) 
app.wm_iconphoto(False, photo) 
ShimejiFrame = customtkinter.CTkFrame(app)






bar = customtkinter.CTkFrame(app, fg_color='#404040', width=510, height=22, corner_radius=0) 
bar.grid(row=0, column=0) 

fileButton = customtkinter.CTkButton(app, command=FileExplorer, fg_color='#292929', hover_color='#242424', text="File", corner_radius=0.2, width=50, height=0.1) 
fileButton.place(x=0, y=0)


DetectShimeji()

app.mainloop()






i tried using the scrollbar element, using another class to do it. i was expecting that the 'ShimejiBlock' would be able to scroll vertically to get more space.

Answer: You can use customtkinter’s scrollable frame to add a scroll bar to the frame instead of using the normal frame and adding one yourself. Change your frame to  this:
frame = customtkinter.CTkScrollableFrame(root, fg_color="#141414", width=250,height=100)