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.
......
# Utilitaire pour création de QRcode
# Utilitaire pour création de QRCode
# Auteur : Daniel SAZERAT
# Projet initié le 24/12/2023
from tkinter import *
import qrcode
from qrcode.constants import ERROR_CORRECT_M
from PIL import Image
# ===== FONCTIONS =====
def new_file():
......@@ -20,6 +22,7 @@ def sel():
def create_code():
if texte.get() != "":
erreur("")
global logo
qr = qrcode.QRCode(
version=3,
......@@ -33,14 +36,22 @@ def create_code():
img.save('qrcode.png')
logo = PhotoImage(file="qrcode.png")
logovisu.config(image=logo)
logovisu.config(image=logo, bg="white")
img = Image.open("qrcode.png")
size = img.size
print(size)
logovisu.place(x=200 - size[0] // 2, y=200 - size[1] // 2)
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
......@@ -75,10 +86,10 @@ root.config(menu=menuBar)
# ===== FRAMES =====
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.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.place(x=0, y=401, width=800, height=240)
......@@ -109,10 +120,10 @@ label.place(x=10, y=10 + 5 * ESP)
# bouton de création du QRCode
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
labelTexte = Label(saisie, text='Texte à coder :', bg="lightgray")
labelTexte = Label(saisie, text='Données à coder :', bg="lightgray")
labelTexte.place(x=10, y=10)
texte = Entry(saisie, width=122)
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