TomSchimansky / CustomTkinter

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

Please make treeview please.. #2037

Open blackCmd opened 10 months ago

blackCmd commented 10 months ago

Please make Treeview please.

I have been using KivyMD, which has a great UI, but it seems to be less readable compared to CustomTkinker. I am trying to transition my KivyMD project to CustomTinker, but it seems that many features provided by KivyMD are missing.

However, CustomTkinker is very intuitive and beautiful.

Can you develop a treeview?

Akascape commented 10 months ago

@blackCmd You can implement the tkinter treeview in customtkinter, see https://github.com/TomSchimansky/CustomTkinter/discussions/524

If you are looking for a table widget then use this: https://github.com/Akascape/CTkTable

There are many widget addons available for customtkinter and tkinter which you can use simultaneously. You can find all of them here: https://github.com/Akascape/tkinter-toolkit (I highly recommend you to explore them, if you are looking for any new widget just search in that application)

MaxNiark commented 10 months ago

FROM a post of akascape in this repository image

self.all_file={}#personnal variable dict
bg_color = self._apply_appearance_mode(customtkinter.ThemeManager.theme["CTkFrame"]["fg_color"])
        text_color = self._apply_appearance_mode(customtkinter.ThemeManager.theme["CTkLabel"]["text_color"])
        selected_color = "green"

        treestyle = ttk.Style()
        treestyle.theme_use('default')
        treestyle.configure("Treeview", 
                            background=bg_color, 
                            foreground=text_color, 
                            fieldbackground=bg_color, 
                            borderwidth=0,font=("Arial", 15)
                            )
        treestyle.map('Treeview', background=[('selected', bg_color)], foreground=[('selected', selected_color)])

        ##Treeview widget data
        self.treeview = ttk.Treeview(frame_1, height=(len(self.all_file)*2), show="tree")
        self.treeview.grid(padx=10)
        for i,v in enumerate(self.all_file):

            self.treeview.insert('', i, v, text =str(v))
            for obj in self.all_file[v]:
                 self.treeview.insert(v, 'end', obj.replace(" ", ""), text =obj)

        self.treeview.bind('<<TreeviewSelect>>', self.on_select)

    def on_select (self,event):
        item = self.treeview.item(element_name)
        selected_item = self.treeview.selection()
        if selected_item:
            item_text = self.treeview.item(selected_item, "text")

FROM Here too and with style ^^ (display is in rework ;) ) image

which one u like ? :)