import tkinter as tk from tkinter import ttk from tkinter.messagebox import showinfo root = tk.Tk() root.title('Treeview demo') root.geometry('620x200') columns = ('DNO', 'DNOM', 'VILLE') tree = ttk.Treeview(root, columns=columns, show='headings') # define headings tree.heading('DNO', text='DNO') tree.heading('DNOM', text='DNOM') tree.heading('VILLE', text='VILLE') tree.column("#1", anchor=tk.CENTER) tree.heading("#1", text="DNO") tree.column("#2", anchor=tk.CENTER) tree.heading("#2", text="DNOM") tree.column("#3", anchor=tk.CENTER) tree.heading("#3", text="VILLE") tree.pack() def View(): D = {12:["KHALDI","CASA"],18:["KHALDI","CASA"],13:["KHALDI","RABAT"]} for x in D.items(): L = [x[0],x[1][0],x[1][1]] tree.insert("", tk.END, values=L) button1 = tk.Button(text="Display data", command=View) button1.pack(pady=10) root.mainloop()