Bonjour à tous
avec bien du mal j'ai adapté un script pour un usage personnel.
Celui-ci affiche deux listes mais dans la deuxième liste je voudrais que ne s'affiche que ce qui est relatif au focus de la ligne de la première liste
excusez moi si je ne suis pas très clair.
je vous donne le script:

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
from tkinter import *
from tkinter import ttk, messagebox
from contact import contact
from appareil import appareil
import sqlite3
import os
import threading
 
 
class Reparation:
    def __init__(self, root_win):
        self.root = root_win
        self.root.geometry("2000x700+0+0")
        self.root.title("Gestion des réparations")
        self.root.config(bg="white")
 
        # Titre de l'écran
        title = Label(self.root, text="Tableau de Bord", font=("Lato", 26, "bold"), bg="white", fg="#343A40", anchor="w", padx=20) # peut ajouter une ancre ici au centre gauche
        title.place(x=200, y=0, relwidth=1, height=70)
 
        # bouton de déconnexion
        logout_btn = Button(self.root, text="Quitter", command=self.logout, font=("Lato", 11, "bold"), bd=0, bg="#F66B0E", fg="white")
        logout_btn.place(x=1180, y=10, height=40, width=120)
 
        # Menu
        menu_frame = Frame(self.root, bd=0, bg="#23282c", relief=RIDGE)
        menu_frame.place(x=0, y=0, width=200, height=400, relheight=1)
 
        menu_label = Label(menu_frame, text="Menu", font=("Lato", 15, "bold"), fg="#313552", bg="#23ba9b")
        menu_label.pack(side=TOP, fill=X)
 
        contacts_btn = Button(menu_frame, text="contact", command=self.contact, font=("Lato", 14, "normal"), bg="#23282c", fg="#a7acb2", bd=0, cursor="hand2")
        contacts_btn.pack(side=TOP, fill=X)
        appareils_btn = Button(menu_frame, text="appareils", command=self.appareils, bg="#23282c", font=("Lato", 14, "normal"), fg="#a7acb2", bd=0, cursor="hand2")
        appareils_btn.pack(side=TOP, fill=X)
 
        # contact list
        contact_list_frame = Frame(self.root, bd=3, relief=RIDGE)
        contact_list_frame.place (x=220, y=100, width=1700, height=250)  #contact_list_frame.place(x=220, y=100, width=1100, height=250)
 
        scroll_y = Scrollbar(contact_list_frame, orient=VERTICAL)
        scroll_x = Scrollbar(contact_list_frame, orient=HORIZONTAL)
        scroll_x.pack(side=BOTTOM, fill=X)
        scroll_y.pack(side=RIGHT, fill=Y)
 
        contact_list_columns = ("id", "nom", "prenom", "adresse", "ville", "tel_fixe", "tel_mobile", "mel", "renseignements")
        self.contact_list_table = ttk.Treeview(contact_list_frame, columns=contact_list_columns, yscrollcommand=scroll_y.set, xscrollcommand=scroll_x.set)
        self.contact_list_table.pack(fill=BOTH, expand=1)
        scroll_x.config(command=self.contact_list_table.xview)
        scroll_y.config(command=self.contact_list_table.yview)
 
        self.contact_list_table.heading("id", text="ID")
        self.contact_list_table.heading("nom", text="Nom")
        self.contact_list_table.heading("prenom", text="Prenom")
        self.contact_list_table.heading("adresse", text="Adresse")
        self.contact_list_table.heading("ville", text="Ville")
        self.contact_list_table.heading("tel_fixe", text="Tel_fixe")
        self.contact_list_table.heading("tel_mobile", text="Tel_mobile")
        self.contact_list_table.heading("mel", text="Mel")
        self.contact_list_table.heading("renseignements", text="Renseignemets")
        self.contact_list_table["show"] = "headings"
 
        self.contact_list_table.column("id", width=10)
        self.contact_list_table.column("nom", width=100)
        self.contact_list_table.column("prenom", width=100)
        self.contact_list_table.column("adresse", width=110)
        self.contact_list_table.column("ville", width=100)
        self.contact_list_table.column("tel_fixe", width=100)
        self.contact_list_table.column("tel_mobile", width=100)
        self.contact_list_table.column("mel", width=100)
        self.contact_list_table.column("renseignements", width=100)
 
 
        # appareils list
        appareils_list_column = Frame(self.root, bd=3, relief=RIDGE)
        appareils_list_column.place(x=220, y=360, width=1700, height=250)  #appareils_list_column.place(x=220, y=350, width=1100, height=250)
 
        scroll_y = Scrollbar(appareils_list_column, orient=VERTICAL)
        scroll_x = Scrollbar(appareils_list_column, orient=HORIZONTAL)
        scroll_x.pack(side=BOTTOM, fill=X)
        scroll_y.pack(side=RIGHT, fill=Y)
 
        appareils_list_columns = ("id", "nom","type", "modele", "panne", "solution", "prix", "id_contact", "date")
        self.appareils_list_table = ttk.Treeview(appareils_list_column, columns=appareils_list_columns, yscrollcommand=scroll_y.set, xscrollcommand=scroll_x.set)
        self.appareils_list_table.pack(fill=BOTH, expand=1)
        scroll_x.config(command=self.appareils_list_table.xview)
        scroll_y.config(command=self.appareils_list_table.yview)
 
        self.appareils_list_table.heading("id", text="ID") 
        self.appareils_list_table.heading("nom", text="Nom")
        self.appareils_list_table.heading("type", text="Type")
        self.appareils_list_table.heading("modele", text="Modele")
        self.appareils_list_table.heading("panne", text="panne")
        self.appareils_list_table.heading("solution", text="Solution")
        self.appareils_list_table.heading("prix", text="Prix")
        self.appareils_list_table.heading("id_contact", text="id_contact")
        self.appareils_list_table.heading("date", text="Date")
        self.appareils_list_table["show"] = "headings"
 
        self.appareils_list_table.column("id", width=10)
        self.appareils_list_table.column("nom", width=100)
        self.appareils_list_table.column("type", width=100)
        self.appareils_list_table.column("modele", width=100)
        self.appareils_list_table.column("panne", width=100)
        self.appareils_list_table.column("solution", width=100)
        self.appareils_list_table.column("prix", width=100)
        self.appareils_list_table.column("id_contact", width=100)
        self.appareils_list_table.column("date", width=100)
 
 
        #footer
        footer = Label(self.root, text="will write footer here later", font=("Lato", 15, "normal"), bg="#2EB086", fg="#313552") # may add anchor here to center left
        footer.place(x=0, y=670, relwidth=1, height=30)
 
        #self.update_content()
        self.show_contact()
        self.show_appareils()
        # ========================================================
 
 
 
    def contact(self):
        self.new_window = Toplevel(self.root)
        self.cont_manager = contact(self.new_window)
 
    def appareils(self):
        self.new_window = Toplevel(self.root)
        self.app_manager = appareil(self.new_window)
 
 
    def logout(self):
        self.root.destroy()
 
 
    def show_contact(self):
        con = sqlite3.connect("reparation.db")
        cur = con.cursor()
        try:
            cur.execute("SELECT * FROM contacts")
            rows = cur.fetchall()
            self.contact_list_table.delete(*self.contact_list_table.get_children())
            for row in rows:
                self.contact_list_table.insert('',END,values=row)
        except Exception as ex:
            messagebox.showerror("Erreur", f"Erreur: {str(ex)}", parent=self.root)
 
    def show_appareils(self):
        con = sqlite3.connect("reparation.db")
        cur = con.cursor()
        try:
            cur.execute("SELECT cont.id, cont.nom, app.type, app.modele, app.panne, app.solution, app.prix, app.ID_contact, app.date FROM contacts cont JOIN appareils app ON cont.id=app.ID_contact ")  # SELECT ls.invoice, p.name, ls.price, ls.qty FROM line_sale ls JOIN product p ON ls.product_id=p.id
            rows = cur.fetchall()
            self.appareils_list_table.delete(*self.appareils_list_table.get_children())
            for row in rows:
                self.appareils_list_table.insert('',END,values=row)
        except Exception as ex:
            messagebox.showerror("Erreur", f"Erreur: {str(ex)}", parent=self.root)
 
 
if __name__ == "__main__":
    root = Tk()
    system = Reparation (root)
    root.mainloop()