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
| from tkinter import *
import tkinter as tk
from tkinter import ttk
fenetre_Creation_Immeuble=Tk()
fenetre_Creation_Immeuble.title('CREATION IMMEUBLE')
fenetre_Creation_Immeuble.geometry("950x750")
fenetre_Creation_Immeuble.configure(bg = "turquoise1")
global Etages
Etages=[[0] *2 for i in range(20)]
def Creation_Canvas_Saisie():
global Etages
NombresEtages=Nbr_Eta.get()
if len (NombresEtages)==0:
return
NombresEtages=int(NombresEtages)
Label(fenetre_Creation_Immeuble,bg='turquoise1',text="Nom Etage", font=("Purisa", 10), anchor="w").place(x=510,y=90,height=20, width=100)
Label(fenetre_Creation_Immeuble,bg='turquoise1',text="Surface en M2", font=("Purisa", 10), anchor="w").place(x=610,y=90,height=20, width=100)
frame = Frame(fenetre_Creation_Immeuble)
frame.place(x=510,y=120)
canvas = Canvas(frame,width=190,height=410)
canvas.pack(side="left", fill="both", expand=True)
scrollbar = ttk.Scrollbar(frame, orient="vertical", command=canvas.yview)
scrollable_frame = Frame(canvas)
scrollbar.pack(side="right", fill="y")
scrollable_frame.bind(
"<Configure>",
lambda e: canvas.configure(
scrollregion=canvas.bbox("all")
)
)
canvas.create_window((0, 0), window=scrollable_frame, anchor="nw")
canvas.configure(yscrollcommand=scrollbar.set)
Etages=[[0] *2 for i in range(NombresEtages)]#tableau a deux dimension pour nom et surface de l'etage
if NombresEtages==1:
Etages[0][0]="Rez De Chaussé"
elif NombresEtages==2:
Etages[0][0]="Rez De Chaussé"
Etages[1][0]="Premier Etage"
else:
Etages[0][0]="Rez De Chaussé"
Etages[1][0]="Premier Etage"
for i in range(2,NombresEtages):
Etages[i][0]=str(i)+" ième Etage"
def OnValidate(Caractere,Chaine,Indice):
if Caractere.isdigit():
if len(Chaine)>=5:
return False
if len(Chaine)<5 and len(Chaine)!=0:
Etages[int(Indice)][1]=int(Chaine)
return True
else:
if len(Chaine)!=1:
Chaine=Chaine[:-1]#pour supprimer le caractere si l'utilisateur tape un cractere alphabetique entre les entier
if len(Chaine)<5 and len(Chaine)!=0:
Etages[int(Indice)][1]=int(Chaine)
return False
for i in range(NombresEtages):
validatecmd = (scrollable_frame.register(OnValidate),'%S', '%P',i)
Label(scrollable_frame, text=Etages[i][0], font=("Purisa", 10)).grid(row=i,column=0,sticky='nsw')
Entry(scrollable_frame,font=("Purisa",10),bg ='bisque', fg='maroon',justify="center",width=10,validate="key", vcmd=validatecmd).grid(row=i,column=1)
LabNbrEta=Label(fenetre_Creation_Immeuble, bg='turquoise1',text="Nombre étages \n 99 Etages Max")
LabNbrEta.place(x=740,y=20, height=30, width=100)
Nbr_Eta=StringVar()
NbrEta=Entry(fenetre_Creation_Immeuble, font=("Purisa", 13), bg='white', justify="left",name="nbreta",textvariable=Nbr_Eta)
NbrEta.place(x=850,y=20, height=25, width=50)
print("NBR etag===",NbrEta)
NbrEta.bind('<Return>', lambda e, : Creation_Canvas_Saisie())
def VOIR_LISTE():
print("------------------liste des etages-------------------")
print(Etages)
Voir_Liste = Button(fenetre_Creation_Immeuble, text = "Voir Liste",bg="green", command = VOIR_LISTE)
Voir_Liste.place(x=500,y=580,height=25, width=100)
fenetre_Creation_Immeuble.mainloop() |
Partager