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 = "" ...@@ -21,18 +21,47 @@ curent_file = ""
# ===== FONCTIONS ===== # ===== 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 # ouverture d'un fichier
def open_file(): def open_file():
global curent_file global curent_file
file = filedialog.askopenfilename(title="Ouvrir un QRCode au format PNG", defaultextension="png", file = filedialog.askopenfilename(title="Ouvrir un QRCode au format PNG", defaultextension="png",
initialdir="./qrcodes") initialdir="./qrcodes")
curent_file = file curent_file = file
ssid_name.delete(0, 'end')
password.delete(0, 'end')
text.delete(0, 'end') text.delete(0, 'end')
text.insert(0, decode(file)) text.insert(0, decode(file))
code() code()
display_qrcode() 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 # lit l'image au format PNG et renvoie le texte
def decode(file): def decode(file):
decoder = cv2.QRCodeDetector() decoder = cv2.QRCodeDetector()
...@@ -92,6 +121,8 @@ def transfert(): ...@@ -92,6 +121,8 @@ def transfert():
else: else:
cache = "" cache = ""
if (crypt != "Aucun" and pwd != "") or (crypt == "Aucun" and password.get() == ""):
# mise à jour du texte à coder # mise à jour du texte à coder
text.delete(0, 'end') text.delete(0, 'end')
code_wifi = "WIFI:T:" + crypt + ";S:" + ssid + ";P:" + pwd + ";H:" + cache code_wifi = "WIFI:T:" + crypt + ";S:" + ssid + ";P:" + pwd + ";H:" + cache
...@@ -100,6 +131,10 @@ def transfert(): ...@@ -100,6 +131,10 @@ def transfert():
# création de l'image du qrcode et affichage # création de l'image du qrcode et affichage
code() code()
display_qrcode() display_qrcode()
else:
messagebox.showerror("Erreur", "Il n'y a pas de mot de passe")
else: else:
messagebox.showerror("Erreur", "Saisissez un SSID") messagebox.showerror("Erreur", "Saisissez un SSID")
...@@ -167,10 +202,10 @@ menu_general = Menu(root) ...@@ -167,10 +202,10 @@ menu_general = Menu(root)
menu_fichier = Menu(menu_general, tearoff=0) menu_fichier = Menu(menu_general, tearoff=0)
menu_general.add_cascade(label="Fichier", menu=menu_fichier) menu_general.add_cascade(label="Fichier", menu=menu_fichier)
# Création des sous menus 'Fichiers' # 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="Ouvrir", command=open_file)
menu_fichier.add_command(label="Enregistrer") 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) menu_fichier.add_command(label="Quitter", command=quit)
# Création du menu principal 'Aide' # Création du menu principal 'Aide'
...@@ -252,8 +287,8 @@ code_btn = Button(left_frame, text="Créer le Code", bg="#88FF88", command=verif ...@@ -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) code_btn.place(x=260, y=380, width=100, height=40)
# texte à coder # texte à coder
texte_title = Label(bottom_frame, text='Données à coder :', bg="#CCCCCC") text_title = Label(bottom_frame, text='Données à coder :', bg="#CCCCCC")
texte_title.place(x=30, y=0) text_title.place(x=30, y=0)
text = Entry(bottom_frame, width=122) text = Entry(bottom_frame, width=122)
text.place(x=30, y=25) 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