Advertisement
Guest User

LogFile

a guest
May 26th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.35 KB | None | 0 0
  1. from tkinter import *
  2. from tkinter.messagebox import *
  3. import tkinter.font as tkFont
  4. import sys
  5.  
  6. # config page
  7. mainapp = Tk()  # Création Fenetre nom 'mainapp'
  8. mainapp.geometry("512x600+256+60")  # taille fenêtre
  9. mainapp.minsize(512, 600)  # taille mlinimale fenêtre
  10. mainapp.maxsize(512, 600)  # taille mlinimale fenêtre
  11. mainapp.title('ıl.lılı Page de test ılıl.lı')  # Titre de la page (en haut à gauche
  12. mainapp['bg'] = '#e5e5e5'  # Couleur du l'arrière plan
  13. mainapp.iconbitmap("Pictures/TextureSol.ico")  # Image de l'icone de la page
  14. fontBasic = tkFont.Font(family='Eras Demi ITC', size=14, weight='normal', slant='roman')
  15. fontBasicLittle = tkFont.Font(family='Eras Light ITC', size=11, weight='normal', slant='italic')
  16. fontBasic2 = tkFont.Font(family='Eurostile', size=14, weight='normal', slant='roman')
  17. fontBasicButton = tkFont.Font(family='PierSans-Bold', size=10, weight='normal', slant='roman')
  18. fontTitle = tkFont.Font(family='OCR A Extended', size=55, weight='normal', slant='roman')
  19. fontArial = tkFont.Font(family='Times', size=10, weight='bold', slant='italic')
  20. fontArial2 = tkFont.Font(family='Times', size=12, weight='normal', slant='roman')
  21.  
  22. # fonction création compte
  23. def registrationConnect():
  24.     if demandePseudoReg.get() == '' or demandeMdpReg.get() == '':
  25.         emptymessage()
  26.     else:
  27.     # Fichier texte
  28.         with open("User.txt", "w") as UserCodesFicReg:
  29.             newPseudo = str(demandePseudoReg.get())
  30.             newMotDePasse = str(demandeMdpReg.get())
  31.             UserCodesFicReg.write("Pseudo: ")
  32.             UserCodesFicReg.write(newPseudo)
  33.             UserCodesFicReg.write("\nMot de passe: ")
  34.             UserCodesFicReg.write(newMotDePasse)
  35.             labelConnected['text'] = ""
  36.             labelRegistered['fg'] = 'green'
  37.             labelRegistered['text'] = "Vous avez modifié votre compte"
  38.             print("Vous avez modifié votre compte!")
  39.             print("Pseudo: ", newPseudo)
  40.             print("Mot de passe: ", newMotDePasse)
  41.             textPseudoReg.delete(0, END)
  42.             textMdpReg.delete(0, END)
  43.  
  44. # fonction connection compte
  45. def verificationConnect():
  46.     with open("User.txt", "r") as UserCodesFicLog:
  47.         UserCodesFicLog.seek(8)
  48.         pseudo = UserCodesFicLog.readline()
  49.         motdePasse = UserCodesFicLog.read(14)
  50.         motdePasse = UserCodesFicLog.readline(14)
  51.  
  52.     if pseudo == demandePseudoLog.get() + "\n" and motdePasse == demandeMdpLog.get():
  53.         labelRegistered['text'] = ""
  54.         labelConnected['fg'] = 'green'
  55.         labelConnected['text'] = "Vous êtes maintenant connecté!"
  56.         print("Connecté!")
  57.         textPseudoLog.delete(0, END)
  58.         textMdpLog.delete(0, END)
  59.         byby()
  60.     else:
  61.         labelRegistered['text'] = ""
  62.         labelConnected['fg'] = 'red'
  63.         labelConnected['text'] = "Erreur!"
  64.         textPseudoLog.delete(0, END)
  65.         textMdpLog.delete(0, END)
  66.         wrongdata()
  67.  
  68.  
  69. # fonction error message
  70. def errormessage():
  71.     showwarning("Erreur!", "Vous ne pouvez pas executer cette action pour le moment")
  72.  
  73. def emptymessage():
  74.     showwarning("Champs vide!", "Veuillez rentrer du texte dans la zone au dessus avant de cliquer sur [OK]")
  75.  
  76. def wrongdata():
  77.     showwarning("Données incorrectes!", "Le nom ou le mot de passe est incorrect, veuillez réessayer")
  78.  
  79. def logged():
  80.     showinfo("Connecté!", "Vous êtes maintenant connecté")
  81.     mainapp.destroy()
  82.  
  83. # fonction quitter
  84. def quitter():
  85.     sys.exit(0)  # Fermer la page
  86.  
  87. # Image
  88. imgScreen = PhotoImage(file="Pictures/Screen1.png")
  89. labelImage = Label(mainapp, image=imgScreen).place(x=-2, y=-20)
  90.  
  91. imgButton = PhotoImage(file="Pictures/Button1.png")
  92.  
  93. # Menu
  94. themenu = Menu(mainapp)
  95. thesousmenu = Menu(themenu, tearoff=0)
  96. themenu.add_cascade(label="Menu", menu=thesousmenu)
  97. thesousmenu.add_command(label="Quitter", command=quitter)
  98. themenu.add_command(label="Commande", command=errormessage)
  99. mainapp.config(menu=themenu)
  100.  
  101.  
  102. title = Label(mainapp,text="Welcome")  # Texte à mettre
  103. title['bg'] = '#B3D9FF'  # ==> Couleur fond texte
  104. title['font'] = fontTitle  # Police de texte
  105. title.place(x=100, y=5)  # Application du texte
  106.  
  107. demandeMdpReg = StringVar()
  108. demandePseudoReg = StringVar()
  109. demandeMdpLog = StringVar()
  110. demandePseudoLog = StringVar()
  111.  
  112. text1 = Label(mainapp,text="Pour créer un compte, c'est ici")  # Texte à mettre
  113. text1['bg'] = '#D5FFFF'  # ==> Couleur fond texte
  114. text1['font'] = fontBasic  # Police de texte
  115. text1.place(x=132, y=190)  # Application du texte
  116.  
  117. textPseudoReg = Entry(mainapp, textvariable=demandePseudoReg)
  118. textPseudoReg['font'] = fontBasic2  # Police de texte
  119. textPseudoReg['bg'] = 'white'
  120. textPseudoReg.place(x=150, y=230)
  121. textMdpReg = Entry(mainapp, textvariable=demandeMdpReg, show="*")
  122. textMdpReg['font'] = fontBasic2  # Police de texte
  123. textMdpReg['bg'] = 'white'
  124. textMdpReg.place(x=150, y=265)
  125.  
  126. recButton = Button(mainapp, text="[OK]", command=registrationConnect)
  127. recButton['text'] = '[OK]'
  128. recButton['font'] = fontBasicButton
  129. recButton['image'] = imgButton
  130. recButton.place(x=245, y=300)
  131.  
  132. text2 = Label(mainapp,text="Pour se connecter à un compte, c'est ici")  # Texte à mettre
  133. text2['bg'] = '#D5FFFF'  # ==> Couleur fond texte
  134. text2['font'] = fontBasic  # Police de texte
  135. text2.place(x=95, y=390)  # Application du texte
  136.  
  137. textPseudoLog = Entry(mainapp, textvariable=demandePseudoLog)
  138. textPseudoLog['font'] = fontBasic2  # Police de texte
  139. textPseudoLog['bg'] = 'white'
  140. textPseudoLog.place(x=150, y=430)
  141. textMdpLog = Entry(mainapp, textvariable=demandeMdpLog, show="*")
  142. textMdpLog['font'] = fontBasic2  # Police de texte
  143. textMdpLog['bg'] = 'white'
  144. textMdpLog.place(x=150, y=465)
  145.  
  146. '''
  147. seSouvenir = 0
  148. souvenir = Checkbutton(mainapp, text="Se souvenir de moi", variable=seSouvenir)
  149. souvenir['bg'] = '#D5FFFF'
  150. souvenir.place(x=195, y=470)
  151. '''
  152.  
  153. logButton = Button(mainapp, text="[OK]", command=verificationConnect)
  154. logButton['text'] = '[OK]'
  155. logButton['font'] = fontBasicButton
  156. logButton['image'] = imgButton
  157. logButton.place(x=245, y=500)
  158.  
  159.  
  160. labelConnected = Label(mainapp)
  161. labelConnected['bg'] = '#D5FFFF'
  162. labelConnected.pack(side='bottom', pady=20)
  163. labelConnected['font'] = fontBasicLittle
  164.  
  165. labelRegistered = Label(mainapp)
  166. labelRegistered['bg'] = '#D5FFFF'
  167. labelRegistered.pack(side='bottom', pady=150)
  168. labelRegistered['font'] = fontBasicLittle
  169.  
  170.  
  171. def byby():
  172.  
  173.     logged()
  174.  
  175. mainapp.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement