-
Notifications
You must be signed in to change notification settings - Fork 632
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #303 from Sai-Uttej-R/main
Added new:the Random Quote Generator project
- Loading branch information
Showing
2 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
```markdown | ||
# Random Quote Generator | ||
|
||
## Overview | ||
|
||
The Random Quote Generator is a simple Python application that fetches and displays random quotes from an online API. Users can click a button to get a new inspiring or funny quote. This project is designed for beginners and includes a graphical user interface (GUI) created using the Tkinter library for a user-friendly experience. | ||
|
||
![Random Quote Generator](screenshot.png) | ||
|
||
## Features | ||
|
||
- Fetch and display a random quote with the click of a button. | ||
- Show the quote along with the author's name. | ||
- Handle internet connection errors gracefully. | ||
- Simple and intuitive GUI for a user-friendly experience. | ||
|
||
## Dependencies | ||
|
||
- Python 3.x | ||
- Tkinter library (usually included with Python) | ||
- Requests library (for making HTTP requests) | ||
|
||
## Getting Started | ||
|
||
1. Clone this repository to your local machine. | ||
|
||
```bash | ||
git clone https://github.com/your-username/random-quote-generator.git | ||
``` | ||
|
||
2. Navigate to the project directory. | ||
|
||
```bash | ||
cd random-quote-generator | ||
``` | ||
|
||
3. Install the `requests` library if you haven't already. | ||
|
||
```bash | ||
pip install requests | ||
``` | ||
|
||
4. Run the Python script. | ||
|
||
```bash | ||
python random_quote_generator.py | ||
``` | ||
|
||
5. The GUI will appear, displaying an initial random quote. Click the "Get a New Quote" button to fetch and display a new quote. | ||
|
||
## How to Contribute | ||
|
||
We welcome contributions to improve and expand this Random Quote Generator project. If you'd like to contribute, follow these steps: | ||
|
||
1. Fork the repository on GitHub. | ||
|
||
2. Clone your forked repository to your local machine. | ||
|
||
```bash | ||
git clone https://github.com/your-username/random-quote-generator.git | ||
``` | ||
|
||
3. Create a new branch for your feature or bug fix. | ||
|
||
```bash | ||
git checkout -b feature/your-feature-name | ||
``` | ||
|
||
4. Make your changes and commit them with descriptive commit messages. | ||
|
||
5. Push your changes to your GitHub repository. | ||
|
||
```bash | ||
git push origin feature/your-feature-name | ||
``` | ||
|
||
6. Create a pull request from your branch to the main repository. | ||
|
||
7. Wait for your pull request to be reviewed and merged. | ||
|
||
## Acknowledgments | ||
|
||
- Thanks to [Quotable API](https://quotable.io/) for providing the quotes. | ||
|
||
## Contact | ||
|
||
If you have any questions, suggestions, or issues, please feel free to contact us at [saiuttej.r@protonmail.com]. | ||
|
||
Happy quoting! 🚀 | ||
``` | ||
Feel free to customize it further to fit your project's specific details and needs. | ||
|
||
This README provides a clear and organized guide for users and potential contributors to understand and interact with your Random Quote Generator project. If you have any more questions or need further assistance, just hit me up, pal! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import requests | ||
import tkinter as tk | ||
|
||
# Function to fetch and display a random quote | ||
def get_random_quote(): | ||
try: | ||
response = requests.get("https://api.quotable.io/random") | ||
data = response.json() | ||
quote = data["content"] | ||
author = data["author"] | ||
quote_text.set(f'"{quote}" - {author}') | ||
except requests.exceptions.RequestException as e: | ||
quote_text.set("Failed to fetch a quote. Check your internet connection.") | ||
|
||
# Create the main window | ||
root = tk.Tk() | ||
root.title("Random Quote Generator") | ||
|
||
# Create a label to display the quote | ||
quote_text = tk.StringVar() | ||
quote_label = tk.Label(root, textvariable=quote_text, wraplength=300, font=("Helvetica", 12)) | ||
quote_label.pack(pady=20) | ||
|
||
# Create a button to get a new quote | ||
new_quote_button = tk.Button(root, text="Get a New Quote", command=get_random_quote) | ||
new_quote_button.pack() | ||
|
||
# Fetch and display an initial random quote | ||
get_random_quote() | ||
|
||
# Start the GUI main loop | ||
root.mainloop() |