diff --git a/.gitignore b/.gitignore index d3408b3..f0c8b9b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -# config/API.config.json +config/API.config.json diff --git a/config/API.config.json b/config/API.config.json index 230fbfe..15ea41a 100644 --- a/config/API.config.json +++ b/config/API.config.json @@ -1,3 +1,3 @@ { - "api_key": "" + "api_key": "6da85901a47efe9f943b1a40bbc727e5" } \ No newline at end of file diff --git a/main.py b/main.py index 1381398..e29d7d4 100644 --- a/main.py +++ b/main.py @@ -3,11 +3,14 @@ import customtkinter as ctk import threading import json import os +import webbrowser app = ctk.CTk() + + def toggleAppearanceMode(): if changeAppearanceMode.get() == 0: mode = "dark" @@ -148,11 +151,6 @@ def checkSystem(): degrees = "°F" changeFromMetric.set(True) - - - - - if os.path.exists("config/config.json"): @@ -169,6 +167,9 @@ if os.path.exists("config/API.config.json"): config = json.load(f) APIKey = config.get("api_key") +def openWeatherLink(event): + webbrowser.open("https://openweathermap.org/api") + def openAPIPopup(): global popup @@ -190,10 +191,14 @@ def openAPIPopup(): APIlabel = ctk.CTkLabel(popup, text="Enter your API key:") - APIlabel.pack(pady=20) + APIlabel.pack(pady=(15, 5)) + + APIKeyGet = ctk.CTkLabel(popup, text="How to get free API key", text_color="#3366d6", cursor="hand2") + APIKeyGet.bind("", openWeatherLink) + APIKeyGet.pack(pady=5) APIEntry = ctk.CTkEntry(popup, placeholder_text="API key...") - APIEntry.pack(pady=10) + APIEntry.pack(pady=0) APIErrorFrame = ctk.CTkFrame(popup, width=450, height=20) APIErrorLabel = ctk.CTkLabel(APIErrorFrame, text="", font=("Arial", 14)) @@ -224,7 +229,6 @@ def openAPIPopup(): if APIcode == 401: def show_error(): - print("401") APIErrorFrame.pack() APIErrorLabel.configure(text="Couldn't access the API key!") APIErrorLabel.pack(padx=10)