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
8cefbb44
Commit
8cefbb44
authored
Dec 29, 2023
by
Thorfin89
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Choix des couleurs sur deux touches.
Affichage des erreurs bugué
parent
ebeb41e4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
68 deletions
+76
-68
README.md
README.md
+16
-5
main.py
main.py
+60
-63
No files found.
README.md
View file @
8cefbb44
### objQRCode
# objQRCode
objQRCode est un utilitaire pour créer des QRCode écrit en python.
Utilitaire pour créer des QRCode écrit en
python.
C'est en faite une interface graphique pour qrcode sous
python.
Ce projet est au tout début de son développement.
## Paquets à installer :
Paquets à installer :
-
qrcode
-
qrcode
-
pillow
-
pillow
## Sources :
### qrcode - python
-
https://pypi.org/project/qrcode/
## similaires :
### segno - python
-
https://segno.readthedocs.io/en/latest/index.html
-
https://www.freecodecamp.org/news/how-to-create-stunning-qr-codes-with-python
main.py
View file @
8cefbb44
...
@@ -4,24 +4,45 @@
...
@@ -4,24 +4,45 @@
from
tkinter
import
*
from
tkinter
import
*
from
tkinter
import
messagebox
from
tkinter
import
messagebox
import
qrcode
from
tkinter.colorchooser
import
askcolor
import
qrcode
from
qrcode.constants
import
ERROR_CORRECT_M
from
qrcode.constants
import
ERROR_CORRECT_M
from
PIL
import
Image
from
PIL
import
Image
COLOR
=
"#000000"
fg_color
=
"#000000"
bg_color
=
"#FFFFFF"
VERSION
=
3
VERSION
=
3
# ===== FONCTIONS =====
# ===== FONCTIONS =====
def
color_selection
():
global
COLOR
# choix de la couleur du fond
selection
=
str
(
color
.
get
())
def
set_bg_color
():
COLOR
=
selection
global
bg_color
(
rgb
,
selection
)
=
askcolor
()
# Appel de la boîte de dialogue 'Couleur'
if
selection
:
bg_color
=
selection
bg_color_btn
.
config
(
bg
=
bg_color
)
if
texte_a_coder
!=
""
:
create_qrcode
()
# choix de la couleur du code
def
set_fg_color
():
global
fg_color
(
rgb
,
selection
)
=
askcolor
()
# Appel de la boîte de dialogue 'Couleur'
if
selection
:
fg_color
=
selection
fg_color_btn
.
config
(
bg
=
fg_color
)
if
texte_a_coder
:
print
(
texte_a_coder
)
create_qrcode
()
def
create_qrcode
():
def
create_qrcode
():
if
texte_a_coder
.
get
()
!=
""
:
global
qrcode_img
global
qrcode_img
bs
=
boxe_size_scale
.
get
()
bs
=
boxe_size_scale
.
get
()
...
@@ -36,7 +57,7 @@ def create_qrcode():
...
@@ -36,7 +57,7 @@ def create_qrcode():
qr
.
add_data
(
texte_a_coder
.
get
())
qr
.
add_data
(
texte_a_coder
.
get
())
qr
.
make
(
fit
=
'True'
)
qr
.
make
(
fit
=
'True'
)
# création et sauvegarde de l'image du QRCode
# création et sauvegarde de l'image du QRCode
img
=
qr
.
make_image
(
fill_color
=
COLOR
,
back_color
=
"white"
)
img
=
qr
.
make_image
(
fill_color
=
fg_color
,
back_color
=
bg_color
)
img
.
save
(
'qrcode.png'
)
img
.
save
(
'qrcode.png'
)
# affichage du QRCode
# affichage du QRCode
qrcode_img
=
PhotoImage
(
file
=
"qrcode.png"
)
qrcode_img
=
PhotoImage
(
file
=
"qrcode.png"
)
...
@@ -45,8 +66,8 @@ def create_qrcode():
...
@@ -45,8 +66,8 @@ def create_qrcode():
img
=
Image
.
open
(
"qrcode.png"
)
img
=
Image
.
open
(
"qrcode.png"
)
size
=
img
.
size
size
=
img
.
size
qrcode_frame
.
place
(
x
=
198
-
size
[
0
]
//
2
,
y
=
198
-
size
[
1
]
//
2
)
# centrage
qrcode_frame
.
place
(
x
=
198
-
size
[
0
]
//
2
,
y
=
198
-
size
[
1
]
//
2
)
# centrage
else
:
messagebox
.
showerror
(
"Erreur"
,
"Il n'y a pas de données à coder"
)
#
messagebox.showerror("Erreur", "Il n'y a pas de données à coder")
# création de la fenêtre principale
# création de la fenêtre principale
...
@@ -89,36 +110,13 @@ bottom_frame.place(x=0, y=421, width=800, height=220)
...
@@ -89,36 +110,13 @@ bottom_frame.place(x=0, y=421, width=800, height=220)
# ===== WIDGETS =====
# ===== WIDGETS =====
# Choix de la couleur
# Choix des couleurs
color
=
StringVar
()
titre_choix_couleur
=
Label
(
left_frame
,
text
=
"Choix de couleurs :"
,
bg
=
"#CCCCCC"
)
color
.
set
(
COLOR
)
titre_choix_couleur
.
place
(
x
=
20
,
y
=
18
)
bg_color_btn
=
Button
(
left_frame
,
bg
=
bg_color
,
relief
=
SUNKEN
,
command
=
set_bg_color
)
titre
=
Label
(
left_frame
,
text
=
"Couleur du QRCode :"
,
bg
=
"#CCCCCC"
)
bg_color_btn
.
place
(
x
=
82
,
y
=
62
,
width
=
20
,
height
=
20
)
titre
.
place
(
x
=
10
,
y
=
20
)
fg_color_btn
=
Button
(
left_frame
,
bg
=
fg_color
,
relief
=
SUNKEN
,
command
=
set_fg_color
)
fg_color_btn
.
place
(
x
=
70
,
y
=
50
,
width
=
20
,
height
=
20
)
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
)
green_btn
=
Radiobutton
(
left_frame
,
bg
=
"#CCCCCC"
,
text
=
"Vert"
,
variable
=
color
,
value
=
"#00FF00"
,
command
=
color_selection
)
violet_btn
=
Radiobutton
(
left_frame
,
bg
=
"#CCCCCC"
,
text
=
"Violet"
,
variable
=
color
,
value
=
"#800080"
,
command
=
color_selection
)
orange_btn
=
Radiobutton
(
left_frame
,
bg
=
"#CCCCCC"
,
text
=
"Orange"
,
variable
=
color
,
value
=
"#FFA500"
,
command
=
color_selection
)
brown_btn
=
Radiobutton
(
left_frame
,
bg
=
"#CCCCCC"
,
text
=
"Marron"
,
variable
=
color
,
value
=
"#6C5417"
,
command
=
color_selection
)
ESP
=
25
# espace entre les boutons radios
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
)
green_btn
.
place
(
x
=
10
,
y
=
20
+
4
*
ESP
)
violet_btn
.
place
(
x
=
10
,
y
=
20
+
5
*
ESP
)
orange_btn
.
place
(
x
=
10
,
y
=
20
+
6
*
ESP
)
brown_btn
.
place
(
x
=
10
,
y
=
20
+
7
*
ESP
)
# choix de la BOXE_SIZE
# choix de la BOXE_SIZE
boxe_size
=
IntVar
()
boxe_size
=
IntVar
()
...
@@ -142,7 +140,6 @@ create_Btn.place(x=260, y=360, width=100, height=40)
...
@@ -142,7 +140,6 @@ create_Btn.place(x=260, y=360, width=100, height=40)
titre_texte_a_coder
=
Label
(
bottom_frame
,
text
=
'Données à coder :'
,
bg
=
"#CCCCCC"
)
titre_texte_a_coder
=
Label
(
bottom_frame
,
text
=
'Données à coder :'
,
bg
=
"#CCCCCC"
)
titre_texte_a_coder
.
place
(
x
=
10
,
y
=
0
)
titre_texte_a_coder
.
place
(
x
=
10
,
y
=
0
)
texte_a_coder
=
Entry
(
bottom_frame
,
width
=
122
)
texte_a_coder
=
Entry
(
bottom_frame
,
width
=
122
)
texte_a_coder
.
insert
(
0
,
"https://objnux.fr"
)
# ligne à supprimer une fois le code validé
texte_a_coder
.
place
(
x
=
30
,
y
=
25
)
texte_a_coder
.
place
(
x
=
30
,
y
=
25
)
# affichage du QRcode
# affichage du QRcode
...
...
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