-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqr code generator.py
70 lines (38 loc) · 1.51 KB
/
qr code generator.py
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
import pyqrcode
import tkinter as tk
from tkinter import *
from PIL import ImageTk, Image
from tkinter import messagebox
def CreateWidgets():
label = Label(text="Enter text : ",bg="#800000")
label.grid(row=0, column=1, padx=5, pady=5)
root.entry = Entry(width=30, textvariable=qrInput)
root.entry.grid(row=0, column=2, padx=5, pady=5)
button = Button(width=10, text="Generate", command=QRCodeGenerate)
button.grid(row=0, column=3, padx=5, pady=5)
label = Label(text="QR Code : ",bg="#800000")
label.grid(row=1, column=1, padx=5, pady=5)
root.imageLabel = Label(root, background="#800000")
root.imageLabel.grid(row=2, column=1, columnspan=3, padx=5, pady=5)
def QRCodeGenerate():
qrString = qrInput.get()
if qrString != '':
qrGenerate = pyqrcode.create(qrString)
qrCodePath = "QR CODE "
qrCodeName = qrCodePath + qrString + ".png"
qrGenerate.png(qrCodeName, scale = 10)
image = Image.open(qrCodeName)
image = image.resize((400,400), Image.ANTIALIAS)
image = ImageTk.PhotoImage(image)
root.imageLabel.config(image=image)
root.imageLabel.photo = image
else:
messagebox.showerror("ERROR", "ENTER A TEXT.!!")
root = tk.Tk()
root.title("QR CODE GENERATOR")
root.geometry("510x500")
root.resizable(False, False)
root.config(background = "#800000")
qrInput = StringVar()
CreateWidgets()
root.mainloop()