Scrollable Frame #241
-
I wanted to know if scrollable frames is possible with ctk and if not is there a reason? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 6 replies
-
Hey ! Don't know if you can achieve this with a label, but I know that you can do it with a Listbox, look at that video to see how it's done : |
Beta Was this translation helpful? Give feedback.
-
In order to create a scrollable region changes could be made inside frame like for example:
Problems to face:
|
Beta Was this translation helpful? Give feedback.
-
Another possibility is to simply override tkinter Scrollbar modifying its theme which is ways faster |
Beta Was this translation helpful? Give feedback.
-
In order to use Scrollbar ctkFrame must be changed: import tkinter
import customtkinter
from tkinter import ttk
ADD_SCROLLBAR = True
TEST_FRAME_COMPATIBILITY = True
customtkinter.set_appearance_mode("dark") # Modes: "System" (standard), "Dark", "Light"
customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"
app = customtkinter.CTk()
app.geometry("400x580")
app.title("CustomTkinter simple_example.py")
def button_callback():
print("Button click", combobox_1.get())
def slider_callback(value):
progressbar_1.set(value)
frame_1 = customtkinter.CTkFrame(master=app)
frame_1.pack(side=tkinter.LEFT, pady=20, padx=60, fill="both", expand=True)
if ADD_SCROLLBAR == True:
#from https://www.pythontutorial.net/tkinter/tkinter-scrollbar/
if TEST_FRAME_COMPATIBILITY == True:
scrollbar = ttk.Scrollbar(app, orient='vertical', command=frame_1.yview)
scrollbar.pack(side=tkinter.RIGHT, fill="y", expand=True)
frame_1['yscrollcommand'] = scrollbar.set
else:
scrollbar = ttk.Scrollbar(app, orient='vertical')
scrollbar.pack(side=tkinter.RIGHT, fill="y", expand=True)
frame_1['yscrollcommand'] = scrollbar.set
label_1 = customtkinter.CTkLabel(master=frame_1, justify=tkinter.LEFT)
label_1.pack(pady=12, padx=10)
progressbar_1 = customtkinter.CTkProgressBar(master=frame_1)
progressbar_1.pack(pady=12, padx=10)
button_1 = customtkinter.CTkButton(master=frame_1, command=button_callback)
button_1.pack(pady=12, padx=10)
slider_1 = customtkinter.CTkSlider(master=frame_1, command=slider_callback, from_=0, to=1)
slider_1.pack(pady=12, padx=10)
slider_1.set(0.5)
entry_1 = customtkinter.CTkEntry(master=frame_1, placeholder_text="CTkEntry")
entry_1.pack(pady=12, padx=10)
optionmenu_1 = customtkinter.CTkOptionMenu(frame_1, values=["Option 1", "Option 2", "Option 42 long long long..."])
optionmenu_1.pack(pady=12, padx=10)
optionmenu_1.set("CTkOptionMenu")
combobox_1 = customtkinter.CTkComboBox(frame_1, values=["Option 1", "Option 2", "Option 42 long long long..."])
combobox_1.pack(pady=12, padx=10)
optionmenu_1.set("CTkComboBox")
checkbox_1 = customtkinter.CTkCheckBox(master=frame_1)
checkbox_1.pack(pady=12, padx=10)
radiobutton_var = tkinter.IntVar(value=1)
radiobutton_1 = customtkinter.CTkRadioButton(master=frame_1, variable=radiobutton_var, value=1)
radiobutton_1.pack(pady=12, padx=10)
radiobutton_2 = customtkinter.CTkRadioButton(master=frame_1, variable=radiobutton_var, value=2)
radiobutton_2.pack(pady=12, padx=10)
switch_1 = customtkinter.CTkSwitch(master=frame_1)
switch_1.pack(pady=12, padx=10)
app.mainloop() I get: AttributeError: 'CTkFrame' object has no attribute 'yview' |
Beta Was this translation helpful? Give feedback.
-
Ask for a new enhaencemnt of CTkFrame, perhaps. About yview and xview: ctk uses its own child of tkinter canvas, and tkinter canvas is a child of Xview and YView, that means it's possible to add scrollbar: tkinter canvas line 1997 tkinter source of YView Class: |
Beta Was this translation helpful? Give feedback.
-
Would love to see this implemented. Would be a huge QoL upgrade. |
Beta Was this translation helpful? Give feedback.
In order to create a scrollable region changes could be made inside frame like for example:
Problems to face: