1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
| #!_*_ coding: latin1 _*_
#! /usr/bin/python
# script mot_de_passe.py
from Tkinter import *
#########################################################################
global x
global y
#definir la limite de la zone contenant l'information
#on definit la fonction case noire et blanche
def caseNoire(x,y):
can.itemconfig(listidrec[x][y],fill='black')
def recuperation() :
global a
a = 0
for p in reference.get():
if p=="w" : #si l'adresse URL ne commence pas par 'www.'=invalide
a += 1
if p=="." :
a += 1
if a==4 :
break
if a==4:
text2 = Label(fen, text ='Votre adresse URL est valide')
text2.pack()
for t in reference.get():
g = ('0'+ bin(ord(t))[2:].zfill(7)) #on recupère l'url et on converti ces caracteres en binaire
print (g)
for x in range(0, 28):
for y in range(0, 28):
for i in range(len(g)):
if g[i]=='1':
caseNoire(x,y)
i=i+1 #1=case noire, 0=case blanche
y=y-1 #on détermine le sens de codage des binaire dans la matrice
x=x+1
else:
text3 = Label(fen, text =' Votre adresse URL est invalide, veuillez recommencer ')
text3.pack()
# l'adresse est invalide, un message nous dit de taper un nouvel URL
#########################################################################
#fenetre principale avec les différents modules
fen=Tk()
fen.title('Generateur de QR Code')
text1 = Label(fen, text = 'Entrez votre adresse URL :', font = 'bold')
bou1 = Button(fen, text = "Quitter",activebackground = 'white', font = 'bold', command = fen.destroy)
bou2 = Button(fen, text = 'Générer',activebackground = 'white', font = 'bold', command = recuperation)
reference = StringVar()
entree = Entry(fen, textvariable = reference)
can = Canvas(fen,height= 580, width = 580, bg = 'white')
can.pack(side=LEFT)
text1.pack(padx = 7)
entree.pack(padx = 5, pady = 7)
bou2.pack(padx = 5)
bou1.pack(side=BOTTOM, padx = 5)
########################################################################
N = 29
pas=580/N
listidrec=N*[[]] #liste pour la matrice
for x in range(N): #creation de la grille avec la matrice
listidrec[x]=N*[-1]
for x in range(N):
for y in range(N):
listidrec[x][y] = can.create_rectangle(pas*x, pas*y, pas*(x+1), pas*(y+1), fill='white')
#######################################################################
#On definit les carrés non variables dans la grille
can.create_rectangle(10,10,130,130,width=20) #dessine le rectangle 7x7 en haut à* gauche
can.create_rectangle(450,10,570,130,width=20) #en haut à* droite
can.create_rectangle(10,450,130,570,width=20) #en bas à* gauche
can.create_rectangle(40,40,100,100,fill="black") #dessine le rectangle 3x3 en haut à* gauche
can.create_rectangle(480,40,540,100,fill="black") #en haut à* droite
can.create_rectangle(40,480,100,540,fill="black") #en bas à* gauche
can.itemconfig(listidrec[6][8],fill='black') # timing paterns de gauche
can.itemconfig(listidrec[6][10],fill='black')
can.itemconfig(listidrec[6][12],fill='black')
can.itemconfig(listidrec[6][14],fill='black')
can.itemconfig(listidrec[6][16],fill='black')
can.itemconfig(listidrec[6][18],fill='black')
can.itemconfig(listidrec[6][20],fill='black')
can.itemconfig(listidrec[8][6],fill='black') #timing paterns du haut
can.itemconfig(listidrec[10][6],fill='black')
can.itemconfig(listidrec[12][6],fill='black')
can.itemconfig(listidrec[14][6],fill='black')
can.itemconfig(listidrec[16][6],fill='black')
can.itemconfig(listidrec[18][6],fill='black')
can.itemconfig(listidrec[20][6],fill='black')
can.create_rectangle(410,410,490,490,width=20) #dessine le petit rectangle en bas a droite
can.itemconfig(listidrec[22][22],fill='black')
#####################################################################################
fen.mainloop() |
Partager