Initial commit
This commit is contained in:
BIN
Glados.png
Executable file
BIN
Glados.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 MiB |
BIN
__pycache__/wetter_api.cpython-314.pyc
Normal file
BIN
__pycache__/wetter_api.cpython-314.pyc
Normal file
Binary file not shown.
71
api_test.py
Executable file
71
api_test.py
Executable file
@@ -0,0 +1,71 @@
|
||||
import requests
|
||||
|
||||
|
||||
|
||||
WMO_CODES = {
|
||||
0: "Klarer Himmel",
|
||||
1: "Hauptsächlich klar",
|
||||
2: "Teils bewölkt",
|
||||
3: "Bedeckt",
|
||||
45: "Nebel",
|
||||
48: "Ablagernder Rauhreifnebel",
|
||||
51: "Leichter Nieselregen",
|
||||
53: "Mäßiger Nieselregen",
|
||||
55: "Dichter Nieselregen",
|
||||
56: "Leichter gefrierender Nieselregen",
|
||||
57: "Dichter gefrierender Nieselregen",
|
||||
61: "Leichter Regen",
|
||||
63: "Mäßiger Regen",
|
||||
65: "Starker Regen",
|
||||
66: "Leichter gefrierender Regen",
|
||||
67: "Starker gefrierender Regen",
|
||||
71: "Leichter Schneefall",
|
||||
73: "Mäßiger Schneefall",
|
||||
75: "Starker Schneefall",
|
||||
77: "Schneegriesel", # Dein Code für morgen!
|
||||
80: "Leichte Regenschauer",
|
||||
81: "Mäßige Regenschauer",
|
||||
82: "Starke Regenschauer",
|
||||
85: "Leichte Schneeschauer",
|
||||
86: "Starke Schneeschauer",
|
||||
95: "Gewitter",
|
||||
96: "Gewitter mit leichtem Hagel",
|
||||
99: "Gewitter mit starkem Hagel"
|
||||
}
|
||||
|
||||
def get_braunschweig_weather():
|
||||
# Koordinaten für Braunschweig
|
||||
url = "https://api.open-meteo.com/v1/forecast"
|
||||
params = {
|
||||
"latitude": 52.2659,
|
||||
"longitude": 10.5267,
|
||||
"daily": "temperature_2m_max,temperature_2m_min,weathercode",
|
||||
"timezone": "Europe/Berlin",
|
||||
"forecast_days": 3
|
||||
}
|
||||
|
||||
try:
|
||||
response = requests.get(url, params=params)
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
|
||||
print(f"Wettervorhersage für Braunschweig (nächste {params['forecast_days']} Tage):")
|
||||
print("-" * 50)
|
||||
|
||||
daily = data['daily']
|
||||
for i in range(len(daily['time'])):
|
||||
date = daily['time'][i]
|
||||
print(type(date))
|
||||
max_temp = daily['temperature_2m_max'][i]
|
||||
min_temp = daily['temperature_2m_min'][i]
|
||||
# Ein einfacher Mapper für Wettercodes (WMO Standard)
|
||||
code = daily['weathercode'][i]
|
||||
|
||||
print(f"Datum: {date} | Max: {max_temp}°C | Min: {min_temp}°C | Code: {WMO_CODES[code]}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Fehler bei der Abfrage: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
get_braunschweig_weather()
|
||||
|
||||
11
datetest.py
Normal file
11
datetest.py
Normal file
@@ -0,0 +1,11 @@
|
||||
test_datum = '2026-02-08'
|
||||
|
||||
|
||||
wechesel = test_datum.split('-')
|
||||
|
||||
jahr = wechesel[0]
|
||||
monat = wechesel[1]
|
||||
tag = wechesel[2]
|
||||
print(f'{tag}.{monat}.{jahr}')
|
||||
|
||||
|
||||
BIN
diablo_arfTu.zip
Executable file
BIN
diablo_arfTu.zip
Executable file
Binary file not shown.
82
main.py
Executable file
82
main.py
Executable file
@@ -0,0 +1,82 @@
|
||||
import tkinter as tk
|
||||
from PIL import Image, ImageTk
|
||||
from wetter_api import get_braunschweig_wetter
|
||||
|
||||
|
||||
#Fenster
|
||||
root = tk.Tk()
|
||||
#Fenstername
|
||||
root.title("GLaDOS βφ")
|
||||
|
||||
#Backgroundfarbedefinition
|
||||
bg_color ="#000000"
|
||||
#Schriftfarbendefinition
|
||||
fg_color ="#ff0000"
|
||||
|
||||
#Fensterhintergrund
|
||||
root.configure(bg=bg_color)
|
||||
|
||||
#Fontanpassungen
|
||||
my_font = ("Diablo",35)
|
||||
|
||||
#Fenstericon Umwandeln
|
||||
img_original = Image.open("Glados.png")
|
||||
img_resized = img_original.resize((64,64),Image.Resampling.LANCZOS)
|
||||
icon_img = ImageTk.PhotoImage(img_resized)
|
||||
root.iconphoto(False, icon_img)
|
||||
|
||||
#Deffinition der Startweite vom Fenster
|
||||
window_width = 800 #fix ggf für pi bildschirm
|
||||
window_height = 600
|
||||
|
||||
#Abfrage der Bildschirmwerte
|
||||
screen_width = root.winfo_screenwidth()
|
||||
screen_height = root.winfo_screenheight()
|
||||
|
||||
#Berechnung für Mitte des Bildschirms
|
||||
center_x = int(screen_width/2 - window_width/2)
|
||||
center_y = int(screen_height/2 - window_height/2)
|
||||
|
||||
#Fenstergeometrie Definition
|
||||
root.geometry(f"{window_width}x{window_height}+{center_x}+{center_y}")
|
||||
|
||||
#Funktion für Vollbild (not statment für F11 an und aus = einem Schalter)
|
||||
def toggle_fullscreen(event=None):
|
||||
root.attributes("-fullscreen",not root.attributes("-fullscreen"))
|
||||
|
||||
#Funktion für Vollbild beenden alternativ
|
||||
def end_fullscreen(event=None):
|
||||
root.attributes("-fullscreen",False)
|
||||
|
||||
#Tastendefinitionen
|
||||
root.bind("<F11>", toggle_fullscreen)
|
||||
root.bind("<Escape>", end_fullscreen)
|
||||
|
||||
#untere Leiste Definition
|
||||
status = tk.Label(
|
||||
root,
|
||||
text="F11: Vollbild | ESC: Beenden",
|
||||
anchor="w",# Links
|
||||
padx=10,#10 Pixel vom Randweg
|
||||
bg="#222",#Hintergrundfarbe
|
||||
fg="#ddd"#Schriftfarbe
|
||||
)
|
||||
|
||||
#Leiste ins Fensterpacken
|
||||
status.pack(side="bottom",fill="x")
|
||||
|
||||
#Dinge ins Fenster
|
||||
wetter_daten = get_braunschweig_wetter()
|
||||
|
||||
wetteranzeige =""
|
||||
for tag in wetter_daten:
|
||||
wetteranzeige += f"{tag['Tag']}.{tag['Monat']}.{tag['Jahr']}:von {tag['Min']}°C bis {tag['Max']}°C - {tag['code']}\n"
|
||||
|
||||
|
||||
message = tk.Label(root, text="Wettervorhersage für Braunschweig",fg=fg_color,bg=bg_color,font=my_font).pack()
|
||||
|
||||
wetter = tk.Label(root, text=wetteranzeige, fg=fg_color, bg=bg_color, font=my_font).pack()
|
||||
|
||||
#Fensterloop
|
||||
|
||||
root.mainloop()
|
||||
37
tktester.py
Executable file
37
tktester.py
Executable file
@@ -0,0 +1,37 @@
|
||||
import tkinter as tk
|
||||
from PIL import Image, ImageTk
|
||||
from tkinter import ttk
|
||||
|
||||
root = tk.Tk()
|
||||
root.title("Tkinter Window Demo")
|
||||
#root.geometry("600x480+50+50")
|
||||
my_font=("Diablo",14)
|
||||
root.configure(bg="#000000")
|
||||
tk.Button(root, text="Classic Label").pack()#wenn dann den
|
||||
ttk.Button(root, text="Themed Label").pack()
|
||||
|
||||
img_original = Image.open("Glados.png")
|
||||
|
||||
img_resized = img_original.resize((64,64),Image.Resampling.LANCZOS)
|
||||
|
||||
icon_img = ImageTk.PhotoImage(img_resized)
|
||||
|
||||
root.iconphoto(False, icon_img)
|
||||
|
||||
window_width = 800
|
||||
window_height = 600
|
||||
|
||||
screen_width = root.winfo_screenwidth()
|
||||
screen_height = root.winfo_screenheight()
|
||||
|
||||
center_x = int(screen_width/2 - window_width/2)
|
||||
center_y = int(screen_height/2 - window_height/2)
|
||||
|
||||
root.geometry(f"{window_width}x{window_height}+{center_x}+{center_y}")
|
||||
root.resizable(False,False)
|
||||
#root.attributes("-alpha",0.5)
|
||||
|
||||
message = tk.Label(root, text="Hello World!",bg="#000000",fg="#ffffff",font=my_font).pack()
|
||||
#message.pack()
|
||||
|
||||
root.mainloop()
|
||||
73
wetter_api.py
Executable file
73
wetter_api.py
Executable file
@@ -0,0 +1,73 @@
|
||||
import requests
|
||||
|
||||
|
||||
|
||||
WMO_CODES = {
|
||||
0: "Klarer Himmel",
|
||||
1: "Hauptsächlich klar",
|
||||
2: "Teils bewölkt",
|
||||
3: "Bedeckt",
|
||||
45: "Nebel",
|
||||
48: "Ablagernder Rauhreifnebel",
|
||||
51: "Leichter Nieselregen",
|
||||
53: "Mäßiger Nieselregen",
|
||||
55: "Dichter Nieselregen",
|
||||
56: "Leichter gefrierender Nieselregen",
|
||||
57: "Dichter gefrierender Nieselregen",
|
||||
61: "Leichter Regen",
|
||||
63: "Mäßiger Regen",
|
||||
65: "Starker Regen",
|
||||
66: "Leichter gefrierender Regen",
|
||||
67: "Starker gefrierender Regen",
|
||||
71: "Leichter Schneefall",
|
||||
73: "Mäßiger Schneefall",
|
||||
75: "Starker Schneefall",
|
||||
77: "Schneegriesel", # Dein Code für morgen!
|
||||
80: "Leichte Regenschauer",
|
||||
81: "Mäßige Regenschauer",
|
||||
82: "Starke Regenschauer",
|
||||
85: "Leichte Schneeschauer",
|
||||
86: "Starke Schneeschauer",
|
||||
95: "Gewitter",
|
||||
96: "Gewitter mit leichtem Hagel",
|
||||
99: "Gewitter mit starkem Hagel"
|
||||
}
|
||||
|
||||
def get_braunschweig_wetter():
|
||||
# Koordinaten für Braunschweig
|
||||
url = "https://api.open-meteo.com/v1/forecast"
|
||||
params = {
|
||||
"latitude": 52.2659,
|
||||
"longitude": 10.5267,
|
||||
"daily": "temperature_2m_max,temperature_2m_min,weathercode",
|
||||
"timezone": "Europe/Berlin",
|
||||
"forecast_days": 3
|
||||
}
|
||||
|
||||
try:
|
||||
response = requests.get(url, params=params)
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
daily = data['daily']
|
||||
ergebnis= []
|
||||
for i in range(len(daily['time'])):
|
||||
date = daily['time'][i]
|
||||
wechsel = date.split('-')
|
||||
jahr = wechsel[0]
|
||||
monat = wechsel[1]
|
||||
tag = wechsel[2]
|
||||
tagesdaten = {
|
||||
'Jahr' : jahr,
|
||||
'Monat' : monat,
|
||||
'Tag' : tag,
|
||||
'Max' : daily['temperature_2m_max'][i],
|
||||
'Min' : daily['temperature_2m_min'][i],
|
||||
# Ein einfacher Mapper für Wettercodes (WMO Standard)
|
||||
'code' : WMO_CODES.get(daily['weathercode'][i]),
|
||||
}
|
||||
ergebnis.append(tagesdaten)
|
||||
|
||||
except Exception as e:
|
||||
return [f"Fehler bei der Abfrage: {e}"]
|
||||
|
||||
return ergebnis
|
||||
Reference in New Issue
Block a user