Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from tkinter.messagebox import *
- import tkinter.font as tkFont
- import sys
- # config page
- mainapp = Tk() # Création Fenetre nom 'mainapp'
- mainapp.geometry("512x600+256+60") # taille fenêtre
- mainapp.minsize(512, 600) # taille mlinimale fenêtre
- mainapp.maxsize(512, 600) # taille mlinimale fenêtre
- mainapp.title('ıl.lılı Page de test ılıl.lı') # Titre de la page (en haut à gauche
- mainapp['bg'] = '#e5e5e5' # Couleur du l'arrière plan
- mainapp.iconbitmap("Pictures/TextureSol.ico") # Image de l'icone de la page
- fontBasic = tkFont.Font(family='Eras Demi ITC', size=14, weight='normal', slant='roman')
- fontBasicLittle = tkFont.Font(family='Eras Light ITC', size=11, weight='normal', slant='italic')
- fontBasic2 = tkFont.Font(family='Eurostile', size=14, weight='normal', slant='roman')
- fontBasicButton = tkFont.Font(family='PierSans-Bold', size=10, weight='normal', slant='roman')
- fontTitle = tkFont.Font(family='OCR A Extended', size=55, weight='normal', slant='roman')
- fontArial = tkFont.Font(family='Times', size=10, weight='bold', slant='italic')
- fontArial2 = tkFont.Font(family='Times', size=12, weight='normal', slant='roman')
- # fonction création compte
- def registrationConnect():
- if demandePseudoReg.get() == '' or demandeMdpReg.get() == '':
- emptymessage()
- else:
- # Fichier texte
- with open("User.txt", "w") as UserCodesFicReg:
- newPseudo = str(demandePseudoReg.get())
- newMotDePasse = str(demandeMdpReg.get())
- UserCodesFicReg.write("Pseudo: ")
- UserCodesFicReg.write(newPseudo)
- UserCodesFicReg.write("\nMot de passe: ")
- UserCodesFicReg.write(newMotDePasse)
- labelConnected['text'] = ""
- labelRegistered['fg'] = 'green'
- labelRegistered['text'] = "Vous avez modifié votre compte"
- print("Vous avez modifié votre compte!")
- print("Pseudo: ", newPseudo)
- print("Mot de passe: ", newMotDePasse)
- textPseudoReg.delete(0, END)
- textMdpReg.delete(0, END)
- # fonction connection compte
- def verificationConnect():
- with open("User.txt", "r") as UserCodesFicLog:
- UserCodesFicLog.seek(8)
- pseudo = UserCodesFicLog.readline()
- motdePasse = UserCodesFicLog.read(14)
- motdePasse = UserCodesFicLog.readline(14)
- if pseudo == demandePseudoLog.get() + "\n" and motdePasse == demandeMdpLog.get():
- labelRegistered['text'] = ""
- labelConnected['fg'] = 'green'
- labelConnected['text'] = "Vous êtes maintenant connecté!"
- print("Connecté!")
- textPseudoLog.delete(0, END)
- textMdpLog.delete(0, END)
- byby()
- else:
- labelRegistered['text'] = ""
- labelConnected['fg'] = 'red'
- labelConnected['text'] = "Erreur!"
- textPseudoLog.delete(0, END)
- textMdpLog.delete(0, END)
- wrongdata()
- # fonction error message
- def errormessage():
- showwarning("Erreur!", "Vous ne pouvez pas executer cette action pour le moment")
- def emptymessage():
- showwarning("Champs vide!", "Veuillez rentrer du texte dans la zone au dessus avant de cliquer sur [OK]")
- def wrongdata():
- showwarning("Données incorrectes!", "Le nom ou le mot de passe est incorrect, veuillez réessayer")
- def logged():
- showinfo("Connecté!", "Vous êtes maintenant connecté")
- mainapp.destroy()
- # fonction quitter
- def quitter():
- sys.exit(0) # Fermer la page
- # Image
- imgScreen = PhotoImage(file="Pictures/Screen1.png")
- labelImage = Label(mainapp, image=imgScreen).place(x=-2, y=-20)
- imgButton = PhotoImage(file="Pictures/Button1.png")
- # Menu
- themenu = Menu(mainapp)
- thesousmenu = Menu(themenu, tearoff=0)
- themenu.add_cascade(label="Menu", menu=thesousmenu)
- thesousmenu.add_command(label="Quitter", command=quitter)
- themenu.add_command(label="Commande", command=errormessage)
- mainapp.config(menu=themenu)
- title = Label(mainapp,text="Welcome") # Texte à mettre
- title['bg'] = '#B3D9FF' # ==> Couleur fond texte
- title['font'] = fontTitle # Police de texte
- title.place(x=100, y=5) # Application du texte
- demandeMdpReg = StringVar()
- demandePseudoReg = StringVar()
- demandeMdpLog = StringVar()
- demandePseudoLog = StringVar()
- text1 = Label(mainapp,text="Pour créer un compte, c'est ici") # Texte à mettre
- text1['bg'] = '#D5FFFF' # ==> Couleur fond texte
- text1['font'] = fontBasic # Police de texte
- text1.place(x=132, y=190) # Application du texte
- textPseudoReg = Entry(mainapp, textvariable=demandePseudoReg)
- textPseudoReg['font'] = fontBasic2 # Police de texte
- textPseudoReg['bg'] = 'white'
- textPseudoReg.place(x=150, y=230)
- textMdpReg = Entry(mainapp, textvariable=demandeMdpReg, show="*")
- textMdpReg['font'] = fontBasic2 # Police de texte
- textMdpReg['bg'] = 'white'
- textMdpReg.place(x=150, y=265)
- recButton = Button(mainapp, text="[OK]", command=registrationConnect)
- recButton['text'] = '[OK]'
- recButton['font'] = fontBasicButton
- recButton['image'] = imgButton
- recButton.place(x=245, y=300)
- text2 = Label(mainapp,text="Pour se connecter à un compte, c'est ici") # Texte à mettre
- text2['bg'] = '#D5FFFF' # ==> Couleur fond texte
- text2['font'] = fontBasic # Police de texte
- text2.place(x=95, y=390) # Application du texte
- textPseudoLog = Entry(mainapp, textvariable=demandePseudoLog)
- textPseudoLog['font'] = fontBasic2 # Police de texte
- textPseudoLog['bg'] = 'white'
- textPseudoLog.place(x=150, y=430)
- textMdpLog = Entry(mainapp, textvariable=demandeMdpLog, show="*")
- textMdpLog['font'] = fontBasic2 # Police de texte
- textMdpLog['bg'] = 'white'
- textMdpLog.place(x=150, y=465)
- '''
- seSouvenir = 0
- souvenir = Checkbutton(mainapp, text="Se souvenir de moi", variable=seSouvenir)
- souvenir['bg'] = '#D5FFFF'
- souvenir.place(x=195, y=470)
- '''
- logButton = Button(mainapp, text="[OK]", command=verificationConnect)
- logButton['text'] = '[OK]'
- logButton['font'] = fontBasicButton
- logButton['image'] = imgButton
- logButton.place(x=245, y=500)
- labelConnected = Label(mainapp)
- labelConnected['bg'] = '#D5FFFF'
- labelConnected.pack(side='bottom', pady=20)
- labelConnected['font'] = fontBasicLittle
- labelRegistered = Label(mainapp)
- labelRegistered['bg'] = '#D5FFFF'
- labelRegistered.pack(side='bottom', pady=150)
- labelRegistered['font'] = fontBasicLittle
- def byby():
- logged()
- mainapp.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement