Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions QRCODE-Generator/QRCODE-Generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import qrcode
import tkinter as tk
from PIL import Image, ImageTk
import webbrowser

def generate_qr_code():
input_URL = url_entry.get()

qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=15,
border=4,
)

qr.add_data(input_URL)
qr.make(fit=True)

img = qr.make_image(fill_color="red", back_color="white")
img.save("url_qrcode.png")

# Display the QR code image in the GUI
qr_image = Image.open("url_qrcode.png")
qr_image = qr_image.resize((400, 400), Image.LANCZOS) # Larger size
qr_photo = ImageTk.PhotoImage(qr_image)
qr_label.config(image=qr_photo)
qr_label.image = qr_photo

# Store the URL to open when the QR code is clicked
qr_label.url = input_URL

def open_url(event):
# Open the URL in the default web browser
webbrowser.open(event.widget.url)

# Create a GUI window
window = tk.Tk()
window.title("QR Code Generator")

# Increase the window size
window.geometry("600x600")

# Create and place a label for the URL input
url_label = tk.Label(window, text="Enter the URL:", font=("Arial", 14))
url_label.pack(pady=10) # Adds vertical spacing

url_entry = tk.Entry(window, font=("Arial", 14))
url_entry.pack(pady=10) # Adds vertical spacing

# Create and place a button to generate the QR code
generate_button = tk.Button(window, text="Generate QR Code", command=generate_qr_code, font=("Arial", 14))
generate_button.pack(pady=10) # Adds vertical spacing

# Create a label to display the generated QR code
qr_label = tk.Label(window)
qr_label.pack(pady=10) # Adds vertical spacing

# Bind a click event to the QR code label
qr_label.bind("<Button-1>", open_url)

# Start the GUI main loop
window.mainloop()
50 changes: 50 additions & 0 deletions QRCODE-Generator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# QRCODE
QRCODE generator using python

# QR Code Generator with GUI

This Python application allows you to generate QR codes for website URLs with a graphical user interface (GUI). Users can input a URL, and the program generates and displays the QR code in the GUI. Additionally, clicking on the generated QR code will open the URL in the default web browser.

## Prerequisites

To run this application, you need to have Python installed on your system. The code relies on the following Python libraries:

- `qrcode`: For generating QR codes.
- `tkinter`: For creating the GUI.
- `Pillow` (PIL Fork): For image processing and displaying the QR code.
- `webbrowser`: For opening URLs in the default web browser.

You can install the required libraries using `pip`:

## shell
`pip install qrcode[pil] pillow`

## Usage
Clone this repository or download the main.py file.
Run the application by executing the main.py script.

## shell

Copy code
python main.py
A GUI window will open with the following elements:

A label and text entry field for entering a URL.
A button to generate the QR code.
A label to display the generated QR code.
Enter a URL in the text entry field and click the "Generate QR Code" button.

The program will generate the QR code and display it in the GUI.

Click on the generated QR code, and it will open the URL in your default web browser.

## OUTPUT

<div align= "center">

<img src="assets/img/imgg1.png">
<img src="assets/img/imgg2.png">

</div>
Contributing
Feel free to contribute to this project by submitting issues, feature requests, or pull requests.
Binary file added QRCODE-Generator/assets/img/imgg1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QRCODE-Generator/assets/img/imgg2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.