write an python app that makes customtkinter gui with info about phone numbers, use some…
- User
write an python app that makes customtkinter gui with info about phone numbers, use some free api's without api key and add some tabs to window
- Assistant
write an python app that makes customtkinter gui with info about phone numbers, use some free api's without api key and add some tabs to window
Creating a GUI application using CustomTkinter to gather and display information about phone numbers can be an interesting project. While there are many APIs available for phone number information, most reliable ones require API keys. However, for educational purposes, you can use the phonenumbers library to parse and understand phone numbers without needing an API key. This example won't include extensive data but will demonstrate the principles and the GUI.
First, ensure you have the required libraries:
pip install customtkinter phonenumbers
Now, let's create a basic CustomTkinter application with tabs. The app will include parsing phone numbers and displaying details such as their possible locations and types.
import customtkinter as ctk
import phonenumbers
from phonenumbers import geocoder, carrier
def parse_number(number):
try:
parsed_number = phonenumbers.parse(number)
if phonenumbers.is_valid_number(parsed_number):
location = geocoder.description_for_number(parsed_number, "en")
carrier_name = carrier.name_for_number(parsed_number, "en")
return {"valid": True, "location": location, "carrier": carrier_name}
else:
return {"valid": False, "error": "Invalid phone number"}
except Exception as e:
return {"valid": False, "error": str(e)}
def search_number():
number = entry.get()
result = parse_number(number)
if result["valid"]:
result_label.config(text=f"Location: {result['location']}\nCarrier: {result['carrier']}")
else:
result_label.config(text=f"Error: {result['error']}")
# Initialize CustomTkInter
ctk.set_appearance_mode("dark")
ctk.set_default_color_theme("green")
app = ctk.CTk()
app.geometry("400x300")
app.title("Phone Number Info")
# Create a tab view
tabview = ctk.CTkTabView(app, width=360, height=200)
tabview.pack(pady=20)
# First tab: Number Info
tab_number_info = tabview.add("Number Info")
entry = ctk.CTkEntry(tab_number_info, placeholder_text="Enter phone number")
entry.pack(pady=10)
search_button = ctk.CTkButton(tab_number_info, text="Search", command=search_number)
search_button.pack(pady=5)
result_label = ctk.CTkLabel(tab_number_info, text="")
result_label.pack(pady=10)
# Second tab: About
tab_about = tabview.add("About")
about_label = ctk.CTkLabel(tab_about, text="Phone Number Info App\n\nMade with CustomTkinter")
about_label.pack(pady=20)
app.mainloop()
phonenumbers library is used to parse and validate phone numbers without third-party API calls. It provides basic functionalities like extracting carrier and geolocation data.parse_number function checks if the provided number is valid and extracts location and carrier information.This app is a simple demonstration of creating a GUI in Python using free and open-source libraries. For full-fledged applications, consider using APIs that offer extensive data, but be mindful of privacy and legal guidelines surrounding phone number information.
Not yet included in a published release.