1

Heys Guys,

is there a way to set the height of the CTkScrollableFrame in the customtkinter library below 200 pixels?

Short example:

import customtkinter as ctk

root = ctk.CTk()
frame = ctk.CTkScrollableFrame(root, height=100)
frame.pack()
root.mainloop()

The command height=100 seems to have no effect. If I choose a value greater than 200 the result gets bigger but I can't find a way to make it smaller.

I also tried .grid instead of .pack but it didn't change anything.

Thanks in advance.

Agent00111
  • 35
  • 4

2 Answers2

2

It is a design bug of customtkinter that the default height of the internal scrollbar inside the CTkScrollableFrame widget is 200.

Work around is to set the height of the internal scrollbar explicitly by calling frame._scrollbar.configure(height=0) after creating frame.

import customtkinter as ctk

root = ctk.CTk()
frame = ctk.CTkScrollableFrame(root, height=100)
# set the height of the internal scrollbar to zero
# then it will be expanded vertically to the configured height of "frame"
frame._scrollbar.configure(height=0)
frame.pack()
root.mainloop()
acw1668
  • 40,144
  • 5
  • 22
  • 34
-1

In order change the height of a scroll able frame, you need to use frame.configure()

Here's the code:

import customtkinter as ctk

root = ctk.CTk()
frame = ctk.CTkScrollableFrame(root)
frame.pack()

# The height configure thing
frame.configure(height=100)

root.mainloop()

Don't forget to give me a upvote if it works :)

An0nymous
  • 16
  • 1
  • This doesn't seem to work. Did you actually try it to see if it made the window 100 pixels tall? On my system it remained at 200 pixels. – Bryan Oakley Aug 22 '23 at 16:46
  • I'm sorry but I'm busy with my projects. But this documentation should help you. Here: https://github.com/TomSchimansky/CustomTkinter/wiki/CTkScrollableFrame – An0nymous Aug 23 '23 at 06:36
  • The point is, this solution doesn't work for a height less than 200. – Bryan Oakley Aug 23 '23 at 06:39