This Python program allows users to select and display icons fetched from the GitHub Emojis API.
The application fetches a list of icon names from the GitHub Emojis API and provides the following functionalities:
- Fetch Icons: Fetches a list of icon names from the GitHub Emojis API.
- Display Options:
- Option 1: Print all icons.
- Option 2: Search icons by keyword.
First, create a virtual environment to isolate dependencies:
# Create a virtual environment
python -m venv venv
# Activate the virtual environment
# On Windows
venv\Scripts\activate
# On macOS/Linux
source venv/bin/activate
Install the required libraries using the provided requirements file:
pip install -r requirements.txt
Execute the main program main.py
:
python main.py
-
Option 1: Print all icons
- Calls
print_all_icons()
function to display all available icon names.
- Calls
-
Option 2: Search icons by keyword
- Calls
search_icons_by_keyword()
function to filter icons based on user-entered keyword. - Case-insensitive search that matches icons regardless of case.
- Notifies the user if no icons match the keyword.
- Calls
-
Choose an Icon
- After selecting an option, the user can choose an icon from the displayed list.
- Calls
display_icon(icon_name)
function to display the selected icon using PIL library.
- Handles potential errors during API requests using
requests
library. - Exception handling for opening and displaying images from URLs using PIL.
- Python 3.x
- requests library (for API requests)
- PIL (Pillow) library (for image display)
Upon running the program, users will be prompted to select an option (1 or 2). After choosing an option, they can further select an icon to display.
Learn more about how to open an image from a URL in Python using PIL: