Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
O
objQRcode
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thorfin89
objQRcode
Commits
80f87d1d
Commit
80f87d1d
authored
Dec 25, 2023
by
Thorfin89
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renommage des variables. Nettoyage du code
parent
a4afe82e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
78 deletions
+70
-78
main.py
main.py
+70
-78
No files found.
main.py
View file @
80f87d1d
...
...
@@ -3,135 +3,127 @@
# Projet initié le 24/12/2023
from
tkinter
import
*
from
tkinter
import
messagebox
import
qrcode
from
qrcode.constants
import
ERROR_CORRECT_M
from
PIL
import
Image
COLOR
=
"#000000"
VERSION
=
3
BOXE_SIZE
=
5
BORDER
=
1
# ===== FONCTIONS =====
# ===== FONCTIONS =====
def
new_file
():
pass
def
sel
():
selection
=
str
(
value
.
get
())
label
.
config
(
text
=
selection
)
def
color_selection
():
selection
=
str
(
color
.
get
())
print
(
str
(
selection
))
color_label
.
config
(
text
=
selection
)
def
create_code
():
def
create_
qr
code
():
if
texte
.
get
()
!=
""
:
erreur
(
""
)
global
logo
global
qrcode_img
qr
=
qrcode
.
QRCode
(
version
=
3
,
version
=
VERSION
,
error_correction
=
ERROR_CORRECT_M
,
box_size
=
5
,
border
=
2
box_size
=
BOXE_SIZE
,
border
=
BORDER
)
qr
.
add_data
(
texte
.
get
())
qr
.
make
(
fit
=
'True'
)
img
=
qr
.
make_image
(
fill_color
=
"blue"
,
back_color
=
"white"
)
img
=
qr
.
make_image
(
fill_color
=
COLOR
,
back_color
=
"white"
)
img
.
save
(
'qrcode.png'
)
logo
=
PhotoImage
(
file
=
"qrcode.png"
)
logovisu
.
config
(
image
=
logo
,
bg
=
"white"
)
qrcode_img
=
PhotoImage
(
file
=
"qrcode.png"
)
qrcode_frame
.
config
(
image
=
qrcode_img
,
bg
=
"white"
)
img
=
Image
.
open
(
"qrcode.png"
)
size
=
img
.
size
logovisu
.
place
(
x
=
200
-
size
[
0
]
//
2
,
y
=
200
-
size
[
1
]
//
2
)
else
:
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
)
qrcode_frame
.
place
(
x
=
198
-
size
[
0
]
//
2
,
y
=
198
-
size
[
1
]
//
2
)
else
:
error_label
.
config
(
bg
=
"lightgray"
,
fg
=
"lightgray"
,
text
=
"======================================"
)
error_label
.
place
(
x
=
390
,
y
=
10
)
messagebox
.
showerror
(
"Erreur"
,
"Il n'y a pas de données à coder"
)
# création de la fenêtre principale
root
=
Tk
()
root
.
geometry
(
'800x480+100+100'
)
root
.
title
(
"ObjQRCode"
)
root
.
config
(
bg
=
"
lightgray
"
)
root
.
config
(
bg
=
"
#CCCCCC
"
)
ESP
=
25
# Création de la barre de
s
menus
menu
Bar
=
Menu
(
root
)
# Création de la barre de menus
menu
_general
=
Menu
(
root
)
# Création du menu principal 'Fichier'
menu
Fichier
=
Menu
(
menuBar
,
tearoff
=
0
)
menu
Bar
.
add_cascade
(
label
=
"Fichier"
,
menu
=
menuF
ichier
)
# Création des sous menus
:
menu
F
ichier
.
add_command
(
label
=
"Nouveau"
,
command
=
new_file
)
menu
F
ichier
.
add_command
(
label
=
"Ouvrir"
)
menu
F
ichier
.
add_command
(
label
=
"Enregistrer"
)
menu
F
ichier
.
add_command
(
label
=
"Enregistrer sous"
)
menu
F
ichier
.
add_command
(
label
=
"Quitter"
,
command
=
quit
)
# Création du menu principal '
Fichier
'
menu
Aide
=
Menu
(
menuBar
,
tearoff
=
0
)
menu
Bar
.
add_cascade
(
label
=
"Aide"
,
menu
=
menuA
ide
)
# Création des sous menus
:
menu
A
ide
.
add_command
(
label
=
"Info"
)
menu
_fichier
=
Menu
(
menu_general
,
tearoff
=
0
)
menu
_general
.
add_cascade
(
label
=
"Fichier"
,
menu
=
menu_f
ichier
)
# Création des sous menus
'Fichiers'
menu
_f
ichier
.
add_command
(
label
=
"Nouveau"
,
command
=
new_file
)
menu
_f
ichier
.
add_command
(
label
=
"Ouvrir"
)
menu
_f
ichier
.
add_command
(
label
=
"Enregistrer"
)
menu
_f
ichier
.
add_command
(
label
=
"Enregistrer sous"
)
menu
_f
ichier
.
add_command
(
label
=
"Quitter"
,
command
=
quit
)
# Création du menu principal '
Aide
'
menu
_aide
=
Menu
(
menu_general
,
tearoff
=
0
)
menu
_general
.
add_cascade
(
label
=
"Aide"
,
menu
=
menu_a
ide
)
# Création des sous menus
'Aide'
menu
_a
ide
.
add_command
(
label
=
"Info"
)
# Configuration de la barre des menus
root
.
config
(
menu
=
menu
Bar
)
root
.
config
(
menu
=
menu
_general
)
# ===== FRAMES =====
conf
=
Frame
(
root
,
bg
=
"lightgray"
)
conf
.
place
(
x
=
0
,
y
=
0
,
width
=
380
,
height
=
40
0
)
left_frame
=
Frame
(
root
,
bg
=
"#CCCCCC"
)
# cadre de gauche : configuration
left_frame
.
place
(
x
=
0
,
y
=
0
,
width
=
380
,
height
=
42
0
)
visu
=
Frame
(
root
,
bg
=
"gray"
)
visu
.
place
(
x
=
380
,
y
=
20
,
width
=
400
,
height
=
400
)
right_frame
=
Frame
(
root
,
bg
=
"gray"
)
# cadre de droite : affichage du qrcode
right_frame
.
place
(
x
=
380
,
y
=
20
,
width
=
400
,
height
=
400
)
saisie
=
Frame
(
root
,
bg
=
"lightgray"
)
saisie
.
place
(
x
=
0
,
y
=
401
,
width
=
800
,
height
=
24
0
)
bottom_frame
=
Frame
(
root
,
bg
=
"#CCCCCC"
)
# cadre du bas : saisie des données à coder
bottom_frame
.
place
(
x
=
0
,
y
=
421
,
width
=
800
,
height
=
22
0
)
# ===== WIDGETS =====
# boutons radios de choix
value
=
StringVar
()
value
.
set
(
"OUI"
)
bouton1
=
Radiobutton
(
conf
,
text
=
"Oui"
,
variable
=
value
,
value
=
"OUI"
,
command
=
sel
)
bouton2
=
Radiobutton
(
conf
,
text
=
"Non"
,
variable
=
value
,
value
=
"NON"
,
command
=
sel
)
bouton3
=
Radiobutton
(
conf
,
text
=
"Peut-être"
,
variable
=
value
,
value
=
"JE NE SAIS PAS"
,
command
=
sel
)
bouton1
.
config
(
bg
=
"lightgray"
)
bouton2
.
config
(
bg
=
"lightgray"
)
bouton3
.
config
(
bg
=
"lightgray"
)
bouton1
.
place
(
x
=
10
,
y
=
20
+
ESP
)
bouton2
.
place
(
x
=
10
,
y
=
20
+
2
*
ESP
)
bouton3
.
place
(
x
=
10
,
y
=
20
+
3
*
ESP
)
# titre de la zone de choix
titre
=
Label
(
conf
,
text
=
"CHOIX :"
,
bg
=
"lightgray"
)
# Choix de la couleur
titre
=
Label
(
left_frame
,
text
=
"Couleur du QRCode :"
,
bg
=
"#CCCCCC"
)
titre
.
place
(
x
=
10
,
y
=
20
)
# affichage du choix
label
=
Label
(
conf
,
text
=
"OUI"
,
width
=
20
,
height
=
2
,
borderwidth
=
1
,
relief
=
"solid"
)
label
.
config
(
bg
=
"lightgray"
)
label
.
place
(
x
=
10
,
y
=
10
+
5
*
ESP
)
# boutons radios de choix
color
=
StringVar
()
color
.
set
(
COLOR
)
black_btn
=
Radiobutton
(
left_frame
,
bg
=
"#CCCCCC"
,
text
=
"Noir"
,
variable
=
color
,
value
=
"#000000"
,
command
=
color_selection
)
blue_btn
=
Radiobutton
(
left_frame
,
bg
=
"#CCCCCC"
,
text
=
"Bleu"
,
variable
=
color
,
value
=
"#0000FF"
,
command
=
color_selection
)
red_btn
=
Radiobutton
(
left_frame
,
bg
=
"#CCCCCC"
,
text
=
"Rouge"
,
variable
=
color
,
value
=
"#FF0000"
,
command
=
color_selection
)
black_btn
.
place
(
x
=
10
,
y
=
20
+
ESP
)
blue_btn
.
place
(
x
=
10
,
y
=
20
+
2
*
ESP
)
red_btn
.
place
(
x
=
10
,
y
=
20
+
3
*
ESP
)
# affichage de la couleur choisie
color_label
=
Label
(
left_frame
,
text
=
"#000000"
,
width
=
20
,
height
=
2
,
borderwidth
=
1
,
relief
=
"solid"
)
color_label
.
config
(
bg
=
"#CCCCCC"
)
color_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
=
Button
(
left_frame
,
text
=
"Créer le Code"
,
bg
=
"#CCCCCC"
,
command
=
create_qr
code
)
create_Btn
.
place
(
x
=
260
,
y
=
360
,
width
=
100
,
height
=
40
)
# texte à coder
labelTexte
=
Label
(
saisie
,
text
=
'Données à coder :'
,
bg
=
"lightgray
"
)
labelTexte
.
place
(
x
=
10
,
y
=
1
0
)
texte
=
Entry
(
saisi
e
,
width
=
122
)
texte
.
place
(
x
=
30
,
y
=
40
)
texte_a_coder
=
Label
(
bottom_frame
,
text
=
'Données à coder :'
,
bg
=
"#CCCCCC
"
)
texte_a_coder
.
place
(
x
=
10
,
y
=
0
)
texte
=
Entry
(
bottom_fram
e
,
width
=
122
)
texte
.
place
(
x
=
30
,
y
=
28
)
# affichage du QRcode
logo
=
""
logovisu
=
Label
(
visu
)
logovisu
.
config
(
image
=
logo
)
logovisu
.
place
(
x
=
400
,
y
=
400
)
qrcode_img
=
""
qrcode_frame
=
Label
(
right_frame
)
qrcode_frame
.
config
(
image
=
qrcode_img
)
qrcode_frame
.
place
(
x
=
400
,
y
=
400
)
# on place l'image par défaut hors champ
root
.
mainloop
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment