Open FriesFriday opened 1 month ago
@FriesFriday Labelframe is possible, if you want to use the ttk label frame then also use the sv_ttk dark mode which will match the theme (external module)
import tkinter as tk
from tkinter import ttk
import sv_ttk
import customtkinter as ctk
# Initialize the main window
root = ctk.CTk()
root.title("LabelFrame with svttk and customtkinter")
root.geometry("400x300")
# Apply the svttk dark theme
sv_ttk.set_theme("dark")
ctk.set_appearance_mode("Dark")
# Create a LabelFrame
label_frame = ttk.LabelFrame(root, text="Custom Buttons")
label_frame.pack(padx=20, pady=20, fill="both", expand=True)
# Match the bg color of label frame
style = ttk.Style()
root.config(bg=style.lookup("TLabelFrame", "background"))
# Create customtkinter buttons and add them to the LabelFrame
button1 = ctk.CTkButton(label_frame, text="Button 1")
button1.pack(pady=10)
button2 = ctk.CTkButton(label_frame, text="Button 2")
button2.pack(pady=10)
button3 = ctk.CTkButton(label_frame, text="Button 3")
button3.pack(pady=10)
root.mainloop()
Okay, Is there any way to have an labelframe from customtkinter itself? e.g: CTkLabelframe
@FriesFriday No, for now we don't have any official CTkLabelFrame widget.
When there will be? thanks for your helping
Hey so, I tried the code you gave me and it gave me this error:
error: Traceback (most recent call last): File "C:\Users\Fries\PycharmProjects\pythonProject\Main_Project\f.py", line 24, in <module> button1 = ctk.CTkButton(label_frame, text="Button 1") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Fries\PycharmProjects\pythonProject\.venv\Lib\site-packages\customtkinter\windows\widgets\ctk_button.py", line 106, in __init__ self._draw() File "C:\Users\Fries\PycharmProjects\pythonProject\.venv\Lib\site-packages\customtkinter\windows\widgets\ctk_button.py", line 203, in _draw self._canvas.configure(bg=self._apply_appearance_mode(self._bg_color)) File "C:\Users\Fries\AppData\Local\Programs\Python\Python311\Lib\tkinter\__init__.py", line 1702, in configure return self._configure('configure', cnf, kw) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Fries\AppData\Local\Programs\Python\Python311\Lib\tkinter\__init__.py", line 1692, in _configure self.tk.call(_flatten((self._w, cmd)) + self._options(cnf)) _tkinter.TclError: unknown color name ""
I'm trying to make an labelframe with ctk like an week now and didn't found any tutorials. is there a way that I can use it? thanks!