Added a Label to get API
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
# config/API.config.json
|
||||
config/API.config.json
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"api_key": ""
|
||||
"api_key": "6da85901a47efe9f943b1a40bbc727e5"
|
||||
}
|
||||
@@ -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"
|
||||
@@ -150,11 +153,6 @@ def checkSystem():
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if os.path.exists("config/config.json"):
|
||||
with open("config/config.json", "r") as f:
|
||||
config = json.load(f)
|
||||
@@ -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("<Button-1>", 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)
|
||||
|
||||
Reference in New Issue
Block a user