TomSchimansky / CustomTkinter

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

CTkScrollableFrame's height attribute is not working in grid systems as expected #1362

Open duruburak opened 1 year ago

duruburak commented 1 year ago

In grid systems, normal CTkFrame's height attribute works without a problem, but CTkScrollableFrame's height is not changing for some reason.

import customtkinter

root= customtkinter.CTk()

top_level = customtkinter.CTkToplevel(root, fg_color="gray14")

frame_master = customtkinter.CTkFrame(top_level, fg_color="gray14", bg_color="gray14")
frame_master.pack(fill="both", expand=True)
frame_master.grid_rowconfigure(0, weight=0)
frame_master.grid_rowconfigure(1, weight=0)
frame_master.grid_rowconfigure(2, weight=1)
frame_master.grid_rowconfigure(3, weight=1)
frame_master.grid_columnconfigure(0, weight=1)

frame_0 = customtkinter.CTkFrame(frame_master, height=150, fg_color="red")
frame_0.grid(row=0, sticky="ew")

frame_1 = customtkinter.CTkFrame(master=frame_master, height=50, fg_color="blue")
frame_1.grid(row=1, sticky="ew")

frame_2 = customtkinter.CTkScrollableFrame(master=frame_master, height=1, fg_color="yellow")
frame_2.grid(row=2, sticky="nswe")

frame_3 = customtkinter.CTkFrame(master=frame_master, height=100, fg_color="orange")
frame_3.grid(row=3, sticky="nswe")

root.mainloop()
Akascape commented 1 year ago

@duruburak If you use sticky='nsew' in grid, then height attribute doesn't work.

duruburak commented 1 year ago

@duruburak If you use sticky='nsew' in grid, then height attribute doesn't work.

It works for CTkFrame() though, height attribute works as an initial height value. You change the values and see it yourself.

Akascape commented 1 year ago

It works for CTkFrame() though, height attribute works as an initial height value. You change the values and see it yourself.

@duruburak If you use sticky='nsew' for ctkframe then height doesn't work there.

But yes, ScrollableFrame has a issue with height even if you don't use sticky. The minimum height is set as 200 ig.

duruburak commented 1 year ago

It works for CTkFrame() though, height attribute works as an initial height value. You change the values and see it yourself.

@duruburak If you use sticky='nsew' for ctkframe then height doesn't work there.

But yes, ScrollableFrame has a issue with height even if you don't use sticky. The minimum height is set as 200 ig.

It works as an initial height value. You can see it by changing

frame_3 = customtkinter.CTkFrame(master=frame_master, height=100, fg_color="orange")
frame_3.grid(row=3, sticky="nswe")

to this:

frame_3 = customtkinter.CTkFrame(master=frame_master, height=10, fg_color="orange")
frame_3.grid(row=3, sticky="nswe")

It has sticky="nswe" assigned, it's what I meant and what I also want for CTkScrollableFrame(). I don't expect a static height, I just want an initial height of let's say 10 and I want it to expand proportionally on resize.

Skupydoom commented 1 year ago

I spent about an hour trying to cope with it before I realized that the height parameter has a minimum of 200 pixels.

emircetinmemis commented 1 year ago

This is a problem comes by self._parent_canvas inside the class. Because the scrollbar doesn't change after 200 px, and canvas can't resizes itself after that point. This is what I think.

MaxNiark commented 1 year ago

heey

to change the height of scrollable frame => self.var._scrollbar.configure(height=self._apply_window_scaling(400))