TomSchimansky / CustomTkinter

A modern and customizable python UI-library based on Tkinter
MIT License
10.77k stars 1.03k forks source link

CTkScroollableFrame disable scroolbar #2491

Closed joe00271 closed 3 days ago

joe00271 commented 5 days ago

I want to disable the scroolbar when the content is to small i but i got this error
ValueError: ['scrollbar'] are not supported arguments. Look at the documentation for supported arguments. How to disable the scroolbar ?


  def display_or_undisplay_scroolbar(self):
         self.scrollable_frame_showing.update_idletasks()  
        if self.scrollable_frame_showing.winfo_height() < self.scrollable_frame_showing.winfo_reqheight():
            self.scrollable_frame_showing.configure(scrollbar='both')
        else:
            self.scrollable_frame_showing.configure(scrollbar='none') 
dipeshSam commented 5 days ago

It is an implementation lack. The ScrollableFrame does not have an option to update Scrollbar visibility afterwords.

For instant fix, I created following function for you:

from customtkinter import CTkScrollableFrame, CTkButton
from tkinter import Tk

def toggle_scrollbar(s_frame):
    s_frame.update_idletasks()
    if s_frame._scrollbar.winfo_ismapped():
        s_frame._scrollbar.grid_remove()
    else:
        s_frame._scrollbar.grid()

if __name__ == "__main__":
    app = Tk()

    s_frame = CTkScrollableFrame(app, fg_color="lightblue", width=600, height=400)
    s_frame.pack(padx=50, pady=50)

    button = CTkButton(app, text="Toggle scrollbar", command=lambda: toggle_scrollbar(s_frame))

    button.pack(padx=50, pady=50)

    app.mainloop()

This will be helpful. Regards.

joe00271 commented 3 days ago

@dipeshSam thank's that 's working

dipeshSam commented 3 days ago

@joe00271 Continue your great Tkinter journey. You are welcome. 😊