Initial commit

This commit is contained in:
2026-07-26 13:18:27 +02:00
parent 50fa3b6f91
commit 936178df04
5 changed files with 21 additions and 22 deletions
+1
View File
@@ -0,0 +1 @@
# config/API.config.json
-5
View File
@@ -1,5 +0,0 @@
{
"api_key": "",
"appearance": "",
"system": ""
}
+3
View File
@@ -0,0 +1,3 @@
{
"api_key": ""
}
+4
View File
@@ -0,0 +1,4 @@
{
"appearance": "dark",
"system": "metric"
}
+13 -17
View File
@@ -20,14 +20,14 @@ def toggleAppearanceMode():
try: try:
with open("config.json", "r") as f: with open("config/config.json", "r") as f:
config = json.load(f) config = json.load(f)
except: except:
config = {} config = {}
config["appearance"] = mode config["appearance"] = mode
with open("config.json", "w") as f: with open("config/config.json", "w") as f:
json.dump(config, f, indent=4) json.dump(config, f, indent=4)
@@ -48,14 +48,14 @@ def toggleFromMetric():
checkSystem() checkSystem()
try: try:
with open("config.json", "r") as f: with open("config/config.json", "r") as f:
config = json.load(f) config = json.load(f)
except: except:
config = {} config = {}
config["system"] = system config["system"] = system
with open("config.json", "w") as f: with open("config/config.json", "w") as f:
json.dump(config, f, indent=4) json.dump(config, f, indent=4)
if resultPage.winfo_ismapped(): if resultPage.winfo_ismapped():
@@ -71,8 +71,8 @@ changeAppearanceMode.pack(anchor="w", padx=10, pady=5)
changeFromMetric = ctk.CTkSwitch(switchFrame, text="Change to Imperial System", command=toggleFromMetric) changeFromMetric = ctk.CTkSwitch(switchFrame, text="Change to Imperial System", command=toggleFromMetric)
changeFromMetric.pack(anchor="w", padx=10, pady=5) changeFromMetric.pack(anchor="w", padx=10, pady=5)
if os.path.exists("config.json"): if os.path.exists("config/config.json"):
with open("config.json", "r") as f: with open("config/config.json", "r") as f:
config = json.load(f) config = json.load(f)
mode = config.get("appearance") mode = config.get("appearance")
if mode == "light": if mode == "light":
@@ -155,8 +155,8 @@ def checkSystem():
if os.path.exists("config.json"): if os.path.exists("config/config.json"):
with open("config.json", "r") as f: with open("config/config.json", "r") as f:
config = json.load(f) config = json.load(f)
system = config.get("system", "metric") system = config.get("system", "metric")
checkSystem() checkSystem()
@@ -164,8 +164,8 @@ if os.path.exists("config.json"):
searchPage = ctk.CTkFrame(app, fg_color="transparent") searchPage = ctk.CTkFrame(app, fg_color="transparent")
resultPage = ctk.CTkFrame(app, fg_color="transparent") resultPage = ctk.CTkFrame(app, fg_color="transparent")
if os.path.exists("config.json"): if os.path.exists("config/API.config.json"):
with open("config.json", "r") as f: with open("config/API.config.json", "r") as f:
config = json.load(f) config = json.load(f)
APIKey = config.get("api_key") APIKey = config.get("api_key")
@@ -212,14 +212,14 @@ def openAPIPopup():
APIKey = APIEntry.get() APIKey = APIEntry.get()
try: try:
with open("config.json", "r") as f: with open("config/API.config.json", "r") as f:
config = json.load(f) config = json.load(f)
except: except:
config = {} config = {}
config["api_key"] = APIKey config["api_key"] = APIKey
with open("config.json", "w") as f: with open("config/API.config.json", "w") as f:
json.dump(config, f, indent=4) json.dump(config, f, indent=4)
if APIcode == 401: if APIcode == 401:
@@ -263,9 +263,6 @@ if not APIKey:
searchPage.pack(fill="both", expand=True) searchPage.pack(fill="both", expand=True)
searchPage.pack(pady=200) searchPage.pack(pady=200)
@@ -332,8 +329,7 @@ def searchWeather():
url = f"https://api.openweathermap.org/data/2.5/weather?q={city}&appid={APIKey}&units={system}&lang=en" url = f"https://api.openweathermap.org/data/2.5/weather?q={city}&appid={APIKey}&units={system}&lang=en"
print(system)
print(url)
try: try:
response = requests.get(url, timeout=5) response = requests.get(url, timeout=5)
APIcode = response.status_code APIcode = response.status_code