Commit a4afe82e authored by Thorfin89's avatar Thorfin89

Affichage des erreurs

parent 78c5b98b
### objQRcode ### objQRCode
Utilitaire pour créer des QRcode écrit en python. Utilitaire pour créer des QRCode écrit en python.
Ce projet est au tout début de son développement. Ce projet est au tout début de son développement.
......
# Utilitaire pour création de QRcode # Utilitaire pour création de QRCode
# Auteur : Daniel SAZERAT # Auteur : Daniel SAZERAT
# Projet initié le 24/12/2023 # Projet initié le 24/12/2023
from tkinter import * from tkinter import *
import qrcode import qrcode
from qrcode.constants import ERROR_CORRECT_M from qrcode.constants import ERROR_CORRECT_M
from PIL import Image from PIL import Image
# ===== FONCTIONS ===== # ===== FONCTIONS =====
def new_file(): def new_file():
...@@ -20,6 +22,7 @@ def sel(): ...@@ -20,6 +22,7 @@ def sel():
def create_code(): def create_code():
if texte.get() != "": if texte.get() != "":
erreur("")
global logo global logo
qr = qrcode.QRCode( qr = qrcode.QRCode(
version=3, version=3,
...@@ -33,14 +36,22 @@ def create_code(): ...@@ -33,14 +36,22 @@ def create_code():
img.save('qrcode.png') img.save('qrcode.png')
logo = PhotoImage(file="qrcode.png") logo = PhotoImage(file="qrcode.png")
logovisu.config(image=logo) logovisu.config(image=logo, bg="white")
img = Image.open("qrcode.png") img = Image.open("qrcode.png")
size = img.size size = img.size
print(size)
logovisu.place(x=200 - size[0] // 2, y=200 - size[1] // 2) logovisu.place(x=200 - size[0] // 2, y=200 - size[1] // 2)
else: else:
print("Pas de texte à coder") erreur("Il n'y a pas de données à coder")
def erreur(message):
error_label = Label(saisie)
if message != "":
error_label.config(bg="lightgray", fg="red", text=message)
else:
error_label.config(bg="lightgray", fg="lightgray", text="======================================")
error_label.place(x=390, y=10)
# création de la fenêtre principale # création de la fenêtre principale
...@@ -75,10 +86,10 @@ root.config(menu=menuBar) ...@@ -75,10 +86,10 @@ root.config(menu=menuBar)
# ===== FRAMES ===== # ===== FRAMES =====
conf = Frame(root, bg="lightgray") conf = Frame(root, bg="lightgray")
conf.place(x=0, y=0, width=400, height=400) conf.place(x=0, y=0, width=380, height=400)
visu = Frame(root, bg="gray") visu = Frame(root, bg="gray")
visu.place(x=401, y=0, width=400, height=400) visu.place(x=380, y=20, width=400, height=400)
saisie = Frame(root, bg="lightgray") saisie = Frame(root, bg="lightgray")
saisie.place(x=0, y=401, width=800, height=240) saisie.place(x=0, y=401, width=800, height=240)
...@@ -109,10 +120,10 @@ label.place(x=10, y=10 + 5 * ESP) ...@@ -109,10 +120,10 @@ label.place(x=10, y=10 + 5 * ESP)
# bouton de création du QRCode # bouton de création du QRCode
create_Btn = Button(conf, text="Créer le Code", bg="lightgreen", command=create_code) create_Btn = Button(conf, text="Créer le Code", bg="lightgreen", command=create_code)
create_Btn.place(x=280, y=360, width=100, height=40) create_Btn.place(x=260, y=360, width=100, height=40)
# texte à coder # texte à coder
labelTexte = Label(saisie, text='Texte à coder :', bg="lightgray") labelTexte = Label(saisie, text='Données à coder :', bg="lightgray")
labelTexte.place(x=10, y=10) labelTexte.place(x=10, y=10)
texte = Entry(saisie, width=122) texte = Entry(saisie, width=122)
texte.place(x=30, y=40) texte.place(x=30, y=40)
......
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