Bonjour,
Je développe un programme où la charte graphique exige que le fond soit noir et les écritures en blanc J'utilise des widgets "ttk" et j'ai configuré un objet Style pour le treeview afin de le rendre conforme à la charte graphique. Malheureusement cela ne fonctionne pas. Je vous adresse la partie de code concernée :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 
import os
import tkinter as tk
import tkinter.ttk as ttk
from tkinter import PhotoImage
 
class App(tk.Frame):
    def __init__(self, master, path):
        tk.Frame.__init__(self, master)
        self._img = PhotoImage(file="video.png")  # change to your file path
        self._img1 = PhotoImage(file="dossier.png")
 
        style = ttk.Style(root)
        style.theme_use("clam")
        style.configure("Custom.Treeview.Heading", background="black", foreground="white", relief="flat", fieldbackground="black")
 
        self.tree = ttk.Treeview(self, style='Custom.Treeview')
        self.tree["columns"] = ("one", "two")
        self.tree.tag_configure('#0', background='#000000')
        ysb = tk.Scrollbar(self, orient='vertical', width=5, command=self.tree.yview)
        self.tree.configure(yscroll=ysb.set, height=15)
        self.tree.column('#0', width=300)
        self.tree.heading('#0', text=path, anchor='w')
        self.tree.column('one', width=150)
        self.tree.heading('one', text='Info1')
        self.tree.column('two', width=150)
        self.tree.heading('two', text='Info2')
        abspath = os.path.abspath(path)
        root_node = self.tree.insert('', '0', text=abspath, open=True)
        self.process_directory(root_node, abspath)
 
        self.tree.grid(row=0, column=0, sticky='EW')
        ysb.grid(row=0, column=1, sticky='ns')
        self.grid(sticky='EW')
Merci pour votre contribution

Charles GRIFFE