Suite du programme python

Bonjour,
voici le listing en entier.

les bibliotheque a importer

import tkinter
from cProfile import label
from tkinter import ttk, Tk
from tkinter import *
from subprocess import call
from tkinter import messagebox
import sqlite3

def Retour():
root.destroy()
call([« python », « Principale.py »])

def Ajouter():
matricule = txtNumero.get()
fournisseur = txtfournisseur.get()
telephone = txtTelephone.get()
produit = comboproduit.get()
prix_achat = txtPrix.get()
quantite_achte = txtQuantite.get()

con = sqlite3.connect('achat.db')
cur = con.cursor()

try:
    sql ="INSERT INTO tb_achat (matricule, fournisseur, telephone, produit, prix_achat, quantite_achte) VALUES (%s, %s, %s, %s, %s, %s)"
    val = (matricule, fournisseur, telephone, produit, prix_achat, quantite_achte)
    cur.execute(sql, val)
    con.commit()
    derniereMatricule = cur.lastrowid
    messagebox.showinfo("Information", "Achat ajouter")
    root.destroy()
    call(["python", "Achats.py"])

except Exception as e:
    print(e)
    # retour
    con.rollback()
    con.close()

def Modifier():
matricule = txtNumero.get()
fournisseur = txtfournisseur.get()
telephone = txtTelephone.get()
produit = comboproduit.get()
prix_achat = txtPrix.get()
quantite_achte = txtQuantite.get()

con = sqlite3.connect('achat.db')
cur = con.cursor()


try:
    sql = "update tb_achat set fournisseur=%s, telephone=%s, produit=%s, prix_achat=%s, quantite_achte=%s where matricule=%s"
    val = (fournisseur, telephone, produit, prix_achat, quantite_achte, matricule)
    cur.execute(sql, val)
    con.commit()
    derniereMatricule= cur.lastrowid
    messagebox.showinfo("Information", "Achat modifier")
    root.destroy()
    call(["python", "Achats.py"])

except Exception as e:
    print(e)
    # retour
    con.rollback()
    con.close()

def Supprimer():
matricule = txtNumero.get()

con = sqlite3.connect('achat.db')
cur = con.cursor() 

try:
    sql = "delete from tb_achat where matricule=%s"
    val = (matricule,)
    cur.execute(sql, val)
    con.commit()
    derniereMatricule= cur.lastrowid
    messagebox.showinfo("Information", "Achat Supprimer")
    root.destroy()
    call(["python", "Achats.py"])

except Exception as e:
    print(e)
    # retour
    con.rollback()
    con.close()

ma fenetre

root = Tk()

root.title(" MENU ACHATS « )
root.geometry(« 1350x700+0+0 »)
root.resizable(False, False)
root.configure(background= »#808080")

ajouter le titre

lbltitre = Label(root, borderwidth= 3, relief= SUNKEN
, text = « GESTION DES ACHATS », font=(« Sans Serif », 25), background=« #483D8B », foreground= « #FFFAFA »)
lbltitre.place(x=0, y=0, width=1350, height=100)

detail des

matricule

lblNumero = Label(root, text = « MATRICULE »,font = (« Arial », 18),bg = « #808080 », fg = « white »)
lblNumero.place(x=70, y = 150, width=150)
txtNumero = Entry(root, bd = 4, font=(« Arial »,14))
txtNumero.place(x=250,y= 150, width=150)

fournisseur

lblfournisseur = Label(root, text = « FOURNISSEUR »,font = (« Arial », 18),bg = « #808080 », fg = « white »)
lblfournisseur.place(x=50, y = 200, width=200)
txtfournisseur = Entry(root, bd = 4, font=(« Arial »,14))
txtfournisseur.place(x=250,y= 200, width=300)

numero

lblTelephone = Label(root, text = « TELEPHONE »,font = (« Arial », 18),bg = « #808080 », fg = « white »)
lblTelephone.place(x=70, y = 250, width=150)
txtTelephone = Entry(root, bd = 4, font=(« Arial »,14))
txtTelephone.place(x=250,y= 250, width=300)

achats

lblproduit = Label(root,text=« PRODUIT »,font=(« Arial », 18))
lblproduit.place(x=550, y= 150, width=150,)

comboproduit = ttk.Combobox(root, font=« Arial, 14 »)
comboproduit[‹ values ›] = [‹ ordi ›, ‹ portable ›, ‹ smarphone ›, ‹ autres… ›]
comboproduit.place(x=700, y= 150, width=150)

prix

lblPrix = Label(root, text = « PRIX »,font = (« Arial », 18),bg = « #808080 », fg = « white »)
lblPrix.place(x=550, y = 200, width=150)
txtPrix = Entry(root, bd = 4, font=(« Arial »,14))
txtPrix.place(x=700,y= 200, width=150)

quantite

lblQuantite = Label(root, text = « QUANTITE »,font = (« Arial », 18),bg = « #808080 », fg = « white »)
lblQuantite.place(x=550, y = 250, width=150)
txtQuantite = Entry(root, bd = 4, font=(« Arial »,14))
txtQuantite.place(x=700,y= 250, width=150)

enregistrer

btnenregistrer = Button(root, text=« Enregistrer »,font=(« Arial », 16), bg=« #483D8B », fg=« white », command=Ajouter)
btnenregistrer.place(x=1000,y=140, width=200)

modifier

btnmodifier = Button(root, text=« Modifier »,font=(« Arial », 16), bg=« #483D8B », fg=« white », command=Modifier)
btnmodifier.place(x=1000,y=190, width=200)

supprimer

btnSupprimer = Button(root, text=« Supprimer »,font=(« Arial », 16), bg=« #483D8B », fg=« white », command=Supprimer)
btnSupprimer.place(x=1000,y=240, width=200)

retour

btnRetour = Button(root, text=« Retour »,font=(« Arial », 16), bg=« #483D8B », fg=« white », command=Retour)
btnRetour.place(x=1240,y=240, width=100)

table

table= ttk.Treeview(root, columns= (1, 2, 3, 4, 5, 6),height=10,show=« headings »)
table.place(x=0, y=290, width=1350, height=700)

entete

table.heading(1 , text = « CODE_ACHAT »)
table.heading(2 , text = « FOURNISSEUR »)
table.heading(3 , text = « TELEPHONE »)
table.heading(4 , text = « PRODUIT »)
table.heading(5 , text = « PRIX »)
table.heading(6 , text = « QUANTITE »)

definir les dimentions des colonnes

table.column(1 , width= 50)
table.column(2 , width= 150)
table.column(3 , width= 150)
table.column(4 , width= 100)
table.column(5 , width= 50)
table.column(6 , width= 50)

afficher les informations de la table

con = sqlite3.connect(‹ achat.db ›)
cur = con.cursor()
cur.execute(« select * from tb_achat »)
for row in cur:
table.insert(‹  ›,END, values = row)
con.close()

execution

root.mainloop()

cordialement
kyrob