Replies: 7 comments 8 replies
-
Custom treeview is not currently implemented. But you can use the normal tkinter treeview with customisations. Here is the example:Codeimport tkinter
from tkinter import ttk
import customtkinter
customtkinter.set_appearance_mode("Dark")
customtkinter.set_default_color_theme("blue")
root = customtkinter.CTk()
root.geometry("250x300")
root.title("Treeview x Customtkinter")
frame_1 = customtkinter.CTkFrame(master=root)
frame_1.pack(pady=20, padx=20, fill="both", expand=True)
label = customtkinter.CTkLabel(master=frame_1,text="Treeview")
label.grid(pady=10)
###Treeview Customisation (theme colors are selected)
bg_color = root._apply_appearance_mode(customtkinter.ThemeManager.theme["CTkFrame"]["fg_color"])
text_color = root._apply_appearance_mode(customtkinter.ThemeManager.theme["CTkLabel"]["text_color"])
selected_color = root._apply_appearance_mode(customtkinter.ThemeManager.theme["CTkButton"]["fg_color"])
treestyle = ttk.Style()
treestyle.theme_use('default')
treestyle.configure("Treeview", background=bg_color, foreground=text_color, fieldbackground=bg_color, borderwidth=0)
treestyle.map('Treeview', background=[('selected', bg_color)], foreground=[('selected', selected_color)])
root.bind("<<TreeviewSelect>>", lambda event: root.focus_set())
##Treeview widget data
treeview = ttk.Treeview(frame_1, height=6, show="tree")
treeview.grid(padx=10)
treeview.insert('', '0', 'i1', text ='Python')
treeview.insert('', '1', 'i2', text ='Customtkinter')
treeview.insert('', '2', 'i3', text ='Tkinter')
treeview.insert('i2', 'end', 'Frame', text ='Frame')
treeview.insert('i2', 'end', 'Label', text ='Label')
treeview.insert('i3', 'end', 'Treeview', text ='Treeview')
treeview.move('i2', 'i1', 'end')
treeview.move('i3', 'i1', 'end')
root.mainloop() If you are looking for a table widget, here is one: https://github.com/Akascape/CTkTable |
Beta Was this translation helpful? Give feedback.
-
Hi Akascape, thank you for sharing the code but when I run it I get this error
|
Beta Was this translation helpful? Give feedback.
-
When I try to switch from dark mode to light mode, the treeview appearance is black, when it should be white, would it be possible to make it vary depending on the mode selected? |
Beta Was this translation helpful? Give feedback.
-
Yes I know that, the problem is that in the app I can change the appearance in execution and I don't know what event triggers set_appearance_mode. |
Beta Was this translation helpful? Give feedback.
-
That's great, I was able to solve the problem with customtkinter.AppearanceModeTracker.add(callback). |
Beta Was this translation helpful? Give feedback.
-
how do you add internal padding inside the entry widget? |
Beta Was this translation helpful? Give feedback.
-
Hi guys!!
I'm using this lib in a private project and I'm really enjoying it. Do we have treeview implemented or forecast to implement in the future? :D
Beta Was this translation helpful? Give feedback.
All reactions