Commit 2a770013 authored by Thorfin89's avatar Thorfin89

Menu fichiers en cours de codage : 'enregistrer sous' en cours de codage. 'enregistrer' non codé

parent 711eec84
......@@ -21,18 +21,47 @@ curent_file = ""
# ===== FONCTIONS =====
def new_file():
global curent_file
curent_file = ""
# on vide toutes les zones de saisie
ssid_name.delete(0, 'end')
password.delete(0, 'end')
text.delete(0, 'end')
qrcode_label.place(x=400, y=400)
# ouverture d'un fichier
def open_file():
global curent_file
file = filedialog.askopenfilename(title="Ouvrir un QRCode au format PNG", defaultextension="png",
initialdir="./qrcodes")
curent_file = file
ssid_name.delete(0, 'end')
password.delete(0, 'end')
text.delete(0, 'end')
text.insert(0, decode(file))
code()
display_qrcode()
# enregistrer un fichier sous
def save_as():
global curent_file
if curent_file !="":
file = filedialog.asksaveasfilename(title="Enregistrer le QRCode au format PNG sous",
filetypes=[("Fichier PNG","png")],
defaultextension="png",
initialdir="./qrcodes")
curent_file = file
print(curent_file)
else:
messagebox.showerror("Erreur", "Le fichier est vide")
# lit l'image au format PNG et renvoie le texte
def decode(file):
decoder = cv2.QRCodeDetector()
......@@ -92,6 +121,8 @@ def transfert():
else:
cache = ""
if (crypt != "Aucun" and pwd != "") or (crypt == "Aucun" and password.get() == ""):
# mise à jour du texte à coder
text.delete(0, 'end')
code_wifi = "WIFI:T:" + crypt + ";S:" + ssid + ";P:" + pwd + ";H:" + cache
......@@ -100,6 +131,10 @@ def transfert():
# création de l'image du qrcode et affichage
code()
display_qrcode()
else:
messagebox.showerror("Erreur", "Il n'y a pas de mot de passe")
else:
messagebox.showerror("Erreur", "Saisissez un SSID")
......@@ -167,10 +202,10 @@ menu_general = Menu(root)
menu_fichier = Menu(menu_general, tearoff=0)
menu_general.add_cascade(label="Fichier", menu=menu_fichier)
# Création des sous menus 'Fichiers'
menu_fichier.add_command(label="Nouveau")
menu_fichier.add_command(label="Nouveau", command=new_file)
menu_fichier.add_command(label="Ouvrir", command=open_file)
menu_fichier.add_command(label="Enregistrer")
menu_fichier.add_command(label="Enregistrer sous")
menu_fichier.add_command(label="Enregistrer sous", command=save_as)
menu_fichier.add_command(label="Quitter", command=quit)
# Création du menu principal 'Aide'
......@@ -252,8 +287,8 @@ code_btn = Button(left_frame, text="Créer le Code", bg="#88FF88", command=verif
code_btn.place(x=260, y=380, width=100, height=40)
# texte à coder
texte_title = Label(bottom_frame, text='Données à coder :', bg="#CCCCCC")
texte_title.place(x=30, y=0)
text_title = Label(bottom_frame, text='Données à coder :', bg="#CCCCCC")
text_title.place(x=30, y=0)
text = Entry(bottom_frame, width=122)
text.place(x=30, y=25)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment