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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
| import tkinter as tk
from tkinter.filedialog import *
from tkinter.messagebox import *
import socket
import time
global socket
global client
global log
def Accueil():
global root
root = tk.Tk()
root.title("Espace élèves")
root.config(bg='#A26F65')
root.geometry('1650x1050')
entete = tk.Label(root, text='Bienvenue sur votre espace pedagogique !', font = ('Tw Cen MT', 30))
entete.place(x=490, y=200, anchor='w')
Bouton = tk.Button(root, text ="Espace élèves",command = eleve, font = ('Tw Cen MT', 15), overrelief= 'ridge', bg= "#644C47", fg ="white")
Bouton.place(x=500, y=400, anchor='w')
Bouton = tk.Button(root, text ="Espace professeur",command = prof, font = ('Tw Cen MT', 15), overrelief= 'ridge', bg= "#644C47", fg ="white")
Bouton.place(x=1000, y=400, anchor='w')
Bouton = tk.Button(root, text ='Quitter',command = quitterAccueil, font = ('Tw Cen MT', 15), overrelief= 'ridge', bg= "#6D2414", fg ="white")
Bouton.place(x=1500, y=900, anchor='se' )
root.mainloop()
def prof():
quitterAccueil()
global prof1
prof1 = tk.Tk()
prof1.title("Espace professeurs")
prof1.config(bg='#A26F65')
prof1.geometry('1650x1050')
global usernamePr
usernamePr= tk.StringVar()
Champ = tk.Entry(prof1, textvariable= usernamePr, bg ='bisque', fg='black')
Champ.focus_set()
Champ.place(x=780, y=300, anchor='w')
global Motdepasseprof
Motdepasseprof = tk.StringVar()
Champ = tk.Entry(prof1, textvariable= Motdepasseprof, show='*', bg ='bisque', fg='black')
Champ.focus_set()
Champ.place(x=780, y=330, anchor='w')
Bouton = tk.Button(prof1, text ="Quitter",command = quitterMDPprof, font = ('Tw Cen MT', 15), overrelief= 'ridge', bg= "#6D2414", fg ="white")
Bouton.place(x=1500, y=900, anchor='w')
Bouton = tk.Button(prof1, text ="Valider",command = VerificationProf, font = ('Tw Cen MT', 15), overrelief= 'ridge', bg= "#644C47", fg ="white")
Bouton.place(x=805, y=400, anchor='w')
entete = tk.Label(prof1, text='Saisir votre mot de passe', font = ('Tw Cen MT', 20))
entete.place(x=700, y=200, anchor='w')
Bouton = tk.Button(prof1, text ="Retour",command = RetourAccueilPr, font = ('Tw Cen MT', 15), overrelief= 'ridge', bg= "#6D2414", fg ="white")
Bouton.place(x=1400, y=900, anchor='w')
prof1.mainloop()
def eleve():
quitterAccueil()
global eleve1
eleve1 = tk.Tk()
eleve1.title("Espace élèves")
eleve1.config(bg='#A26F65')
eleve1.geometry('1650x1050')
global usernameEl
usernameEl= tk.StringVar()
Champ = tk.Entry(eleve1, textvariable= usernameEl, bg ='bisque', fg='black')
Champ.focus_set()
Champ.place(x=780, y=300, anchor='w')
global Motdepasseeleve
Motdepasseeleve= tk.StringVar()
Champ = tk.Entry(eleve1, textvariable= Motdepasseeleve, show='*', bg ='bisque', fg='black')
Champ.focus_set()
Champ.place(x=780, y=330, anchor='w')
Bouton = tk.Button(eleve1, text ="Valider",command = VerificationEleve, font = ('Tw Cen MT', 15), overrelief= 'ridge', bg= "#644C47", fg ="white")
Bouton.place(x=805, y=400, anchor='w')
Bouton = tk.Button(eleve1, text ="Quitter",command = quitterMDPeleve, font = ('Tw Cen MT', 15), overrelief= 'ridge', bg= "#6D2414", fg ="white")
Bouton.place(x=1500, y=900, anchor='w')
Bouton = tk.Button(eleve1, text ="Retour",command = RetourAccueilEl, font = ('Tw Cen MT', 15), overrelief= 'ridge', bg= "#6D2414", fg ="white")
Bouton.place(x=1400, y=900, anchor='w')
entete = tk.Label(eleve1, text='Saisir votre mot de passe', font = ('Tw Cen MT', 20))
entete.place(x=700, y=200, anchor='w')
eleve1.mainloop()
def VerificationEleve():
if Motdepasseeleve.get() == 'eleve' and usernameEl.get() == 'username':
showinfo('Validation','Mot de passe correct')
eleve2()
else:
showwarning('Erreur','Mot de passe ou identifiant incorrect !')
Motdepasseeleve.set('')
def VerificationProf():
if Motdepasseprof.get() == 'prof' and usernamePr.get() == 'username':
showinfo('Validation','Mot de passe correct!')
prof2()
else:
showwarning('Erreur','Mot de passe ou identifiant incorrect !')
Motdepasseprof.set('')
def prof2():
quitterMDPprof()
global prof2
prof2 = tk.Tk()
prof2.title("Espace professeurs")
prof2.config(bg='#A26F65')
prof2.geometry('1650x1050')
global gifdict
gifdict={}
entete = tk.Label(prof2, text='Bienvenue à toi jeune prof', font = ('Tw Cen MT', 25))
entete.place(x=650, y=200, anchor='w')
global exoaenvoyer
entete = tk.Label(prof2, text='Envoyer une image', font = ('Tw Cen MT', 15))
entete.place(x=250, y=300, anchor='w')
entete = tk.Label(prof2, text='Envoyer un texte', font = ('Tw Cen MT', 15))
entete.place(x=1250, y=300, anchor='w')
Bouton = tk.Button(prof2, text ="Quitter",command = quitterProf, font = ('Tw Cen MT', 15), overrelief= 'ridge', bg= "#6D2414", fg ="white")
Bouton.place(x=1500, y=900, anchor='w')
Bouton = tk.Button(prof2, text ="Ouvrir une Image",command = OuvrirImage, font = ('Tw Cen MT', 15), overrelief= 'ridge', bg= "#644C47", fg ="white")
Bouton.place(x=250, y=500, anchor='w')
exoaenvoyer = tk.StringVar()
Champ = tk.Entry(prof2, textvariable= exoaenvoyer, bg ='bisque', fg='black')
Champ.focus_set()
Champ.place(x=1170, y=400, anchor='w', width = 300)
Bouton = tk.Button(prof2, text ="Envoyer",command = envoyertext, font = ('Tw Cen MT', 15), overrelief= 'ridge', bg= "#644C47", fg ="white")
Bouton.place(x=1280, y=500, anchor='w')
prof2.mainloop()
def eleve2():
quitterMDPeleve()
global eleve2
eleve2 = tk.Tk()
eleve2.title("Espace élèves")
eleve2.config(bg='#A26F65')
eleve2.geometry('1650x1050')
global log
log = tk.Text(eleve2, width=25, height=20, takefocus=0, font = ('Tw Cen MT', 15))
log.place(x=400, y=310, anchor='w')
global socket
socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.bind(('172.18.189.128', 15555))
chrono = time.time()
global client,adress
while True:
socket.listen(5)
client, address = socket.accept()
print ("{} connected".format( address ))
response = client.recv(255)
if response != "":
response2 = response.decode('utf-8')
log.insert(END, response2)
client.close()
socket.close()
eleve2.mainloop()
def OuvrirImage():
filename = tk.filedialog.askopenfilename(title="Ouvrir une image",filetypes=[('gif files','.gif'),('all files','.*')])
print(filename)
photo = PhotoImage(file=filename)
gifdict[filename] = photo # référence
print(gifdict)
def envoyertext():
exot = exoaenvoyer.get()
hote = "172.18.189.97"
port = 15555
global socket
socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.connect((hote,port))
print ("Connecté au prof")
exot2 = bytes(exot, encoding='utf-8')
socket.send(exot2)
print("Envoyé")
socket.close()
def verifsock():
global socket
socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.bind(('192.168.43.125', 15555))
socket.listen(5)
client, address = socket.accept()
print ("{} connected".format( address ))
response = client.recv(255)
if response != "":
log.insert(END, response)
else:
return
after_id = eleve2.after(10, verifsock)
def quitterAccueil():
root.destroy()
def quitterProf():
prof2.destroy()
def quitterMDPprof():
prof1.destroy()
def quitterMDPeleve():
eleve1.destroy()
def RetourAccueilEl():
eleve1.destroy()
Accueil()
def RetourAccueilPr():
prof1.destroy()
Accueil()
Accueil() |
Partager