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
| from tkinter import *
import PIL
from PIL import Image, ImageTk
import pickle
#--------------------------------------------------------------------
#reglage
#--------------------------------------------------------------------
couleur = (48, 47, 47)
couleurmes = (113, 113, 113)
#--------------------------------------------------------------------
#creation de la class
#--------------------------------------------------------------------
class Appli():
def __init__(self):
self.fenetre = Tk()
self.fenetre.geometry("1020x500")
self.fenetre.title('Appli')
self.fenetre.configure(background="gray11")
self.fenetre.configure(highlightbackground="red")
self.fenetre.configure(borderwidth="10")
self.fenetre.configure(relief="ridge")
self.fenetre.attributes('-alpha', 0.98)
self.objet()
#methode pour objets
def objet(self):
self.listeF = ['NOM :', 'PRENOM :', 'ADRESSE :', 'N° TELE :', 'MAIL :' ]
R_span = 2
R_pady = 60
chemin_fichier = 'kard.png' # Fichier dans le dossier de ce script
#creation graphique
for x in self.listeF:
x = Label(self.fenetre, text=x, bg='gray11', fg='azure')
x.grid(row=1, column=2, rowspan = R_span, padx=30,pady = R_pady, sticky = NW)
x = Entry(self.fenetre, bg='azure', fg='gray11')
x.grid(row=1, column=3, rowspan=R_span ,padx=30, pady= R_pady, sticky = N)
#recuperation de la list
R_span += 1
R_pady +=50
# Label Massage
self.lab_mes = Label(self.fenetre, text='MESSAGE : ', bg='gray11', fg='azure')
self.lab_mes.grid(row=1, column=4, padx=60, rowspan = 2, pady=60, sticky = N)
# Massage
self.MES = Entry(self.fenetre, bg='azure', fg='gray11')
self.MES.grid(row=2, column=4, padx=20, rowspan=1, ipady=55,ipadx=70, pady=0, sticky=N)
# Bouton
self.bouton = Button(self.fenetre, text='Valider',fg="azure", command=self.Entree_Get ,
activeforeground = 'gray11',highlightbackground="gray11", width= 10, height=2,bd =5)
self.bouton.grid(row=2, column=4,rowspan = 3)
# --------------------------------------------------------------------
# creation image photo
# --------------------------------------------------------------------
image = PIL.Image.open("kard.png")
photo = PIL.ImageTk.PhotoImage(image)
# --------------------------------------------------------------------
# creation canvas
# --------------------------------------------------------------------
self.canphoto = Canvas(self.fenetre, width = photo.width(), height = photo.height())
self.canphoto.create_image(40, 60, anchor=NW, image=photo)
self.canphoto.grid(row=1, column=1, rowspan=2, padx=20, pady=60,sticky = W)
#--------------------------------------------------------------------
#creation fishier data
#--------------------------------------------------------------------
self.list_general = []
def savetexte(self, n): # enregistrement des données dans un fichier
fichier = open('data.txt', 'wb')
pickle.dump(n, fichier) # sérialisation
fichier.close()
#def recuptext(self): # récupération des données
# fichier = open('data.txt', 'rb')
# M = pickle.load(fichier) # désérialisation
# fichier.close()
# --------------------------------------------------------------------
#methode du boutton valid
# --------------------------------------------------------------------
def Entree_Get(self):
list_Info = []
self.list_general.append(list_Info)
for widget in self.fenetre.winfo_children():
if widget.winfo_class() == 'Entry':
list_Info.append(widget.get())
self.savetexte(self.list_general)
print(self.list_general)
#variable lié à l'application
application = Appli()
application.fenetre.mainloop() |
Partager