TomSchimansky / CustomTkinter

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

Label is not getting added inside ScrollableFrame! #2383

Closed Sayad-Uddin-Tahsin closed 2 months ago

Sayad-Uddin-Tahsin commented 2 months ago
widgetinfoFrame = ctk.CTkScrollableFrame(mainFrame, width=200, height=mainFrame.cget("height") - 10, border_width=1)
widgetinfoFrame.pack(side="right", padx=5)
# widgetinfoFrame.pack_propagate(0)

ctk.CTkLabel(widgetinfoFrame, text="OK").place(x=10, y=10)

it seems not adding the Label inside the ScrollableFrame! why?

Anonymous6598 commented 2 months ago

only .grid() method works with CTkScrolableFrame. try this:

widgetinfoFrame = ctk.CTkScrollableFrame(mainFrame, width=200, height=mainFrame.cget("height") - 10, border_width=1)
widgetinfoFrame.pack(side="right", padx=5)
# widgetinfoFrame.pack_propagate(0)

ctk.CTkLabel(widgetinfoFrame, text="OK").grid(row=0, column=0, padx=10, pady=10)
rigvedmaanas commented 2 months ago

@Sayad-Uddin-Tahsin Both .pack() and .grid() works with CTkScrollableFrame.

Example code using .pack()

from customtkinter import *

root = CTk()
root.geometry("500x500")
scrollable_frame = CTkScrollableFrame(root, width=300, height=300)
scrollable_frame.pack()

for x in range(40):
    lbl = CTkLabel(scrollable_frame, text="This label is displayed using .pack()")
    lbl.pack()

root.mainloop()

Example code using .grid()

from customtkinter import *

root = CTk()
root.geometry("500x500")
scrollable_frame = CTkScrollableFrame(root, width=300, height=300)
scrollable_frame.pack()

for x in range(40):
    lbl = CTkLabel(scrollable_frame, text="This label is displayed using .grid()")
    lbl.grid(row=x, column=0)

root.mainloop()

Result:

result

Anonymous6598 commented 2 months ago

And what was the issue?

rigvedmaanas commented 2 months ago

And what was the issue?

He couldn't display the label in the CTkScrollableFrame because he used .place().

Anonymous6598 commented 2 months ago

Problem solved

Anonymous6598 commented 2 months ago

just use for loop and there you go

Anonymous6598 commented 2 months ago

@rigvedmaanas, thanks for assistance.

Sayad-Uddin-Tahsin commented 2 months ago

Thanks for the help @Anonymous6598 @rigvedmaanas!

Anonymous6598 commented 2 months ago

Your welcome