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
| from tkinter import *
from tkinter import ttk
Fenetre_Creation_Facture=Tk()
Fenetre_Creation_Facture.geometry("1100x700")
Fenetre_Creation_Facture.configure(bg = "turquoise1")
LabelFrameLignesFacture=LabelFrame(Fenetre_Creation_Facture, text="LIGNES FACTURE",bg='yellow')
FrameLignesFacture = Frame(LabelFrameLignesFacture,bg='red')
Canvas_LignesFacture = Canvas(FrameLignesFacture)
Canvas_LignesFacture.pack(side="left", fill="both", expand=True)
Scrollable_Frame = Frame(Canvas_LignesFacture)
Scrollbar =ttk.Scrollbar(FrameLignesFacture, orient="vertical", command=Canvas_LignesFacture.yview)
Scrollbar.pack(side="right", fill="y")
Scrollable_Frame.bind(
"<Configure>",
lambda e: Canvas_LignesFacture.configure(
scrollregion=Canvas_LignesFacture.bbox("all")
)
)
Canvas_LignesFacture.create_window((0, 0), window=Scrollable_Frame, anchor="nw")
Canvas_LignesFacture.configure(yscrollcommand=Scrollbar.set)
ListeLignesFacture=[]
def Ajouter_Ligne(Event, NumBouton):
if NumBouton<49:
#ListeLignesFacture[NumBouton+1]["Frame_Ligne"].configure(height=(30*NumBouton+2))
if NumBouton<9:
FrameLignesFacture.place_forget()
FrameLignesFacture.place(x=10,y=45, height=(30*(NumBouton+2)), width=515)
ListeLignesFacture[NumBouton+1]["Frame_Ligne"].grid(row=NumBouton+1,column=1)
ListeLignesFacture[NumBouton+1]["ChoixEncaissement"].place(x=10,y=5, height=20, width=380)
ListeLignesFacture[NumBouton+1]["Text_Montant"].place(x=395,y=5, height=20, width=70)
ListeLignesFacture[NumBouton+1]["Bouton+"].place(x=470,y=5, height=20, width=20)
for i in range(50):
FrameLigne=Frame(Scrollable_Frame,bg='yellow',height=30, width=500)
Nom="encaissement"+str(i)
Choix_Encaissement = StringVar()
ChoixEncaissement = ttk.Combobox(FrameLigne, state = 'readonly',height=20, width=50,values='-----------CHOIX----------',name=Nom,textvariable = Choix_Encaissement)
ChoixEncaissement.current(0)
TextMontant=Label(FrameLigne,text="",height=1, width=10,bg='red',anchor="w")
Bouton=Button(FrameLigne, font=("Purisa", 17),text = "+",bg="green",name="bouton"+str(i))
def IdentifierBouton(Event, i=i):
return Ajouter_Ligne(Event, i)
Bouton.bind('<Button-1>', IdentifierBouton)
ListeLignesFacture.append({"Frame_Ligne":FrameLigne,"Choix_Encaissement":Choix_Encaissement,"ChoixEncaissement":ChoixEncaissement,"Text_Montant":TextMontant,"Bouton+":Bouton})
LabelFrameLignesFacture.place(x=10,y=320, height=370, width=730)
FrameLignesFacture.place(x=10,y=45, height=30, width=515)
ListeLignesFacture[0]["Frame_Ligne"].grid(row=0,column=1)
ListeLignesFacture[0]["ChoixEncaissement"].place(x=10,y=5, height=20, width=380)
ListeLignesFacture[0]["Text_Montant"].place(x=395,y=5, height=20, width=70)
ListeLignesFacture[0]["Bouton+"].place(x=470,y=5, height=20, width=20)
Fenetre_Creation_Facture.mainloop() |
Partager