This commit is contained in:
sankalp committed 2024-11-22 20:36:57 +05:45
1 parent 721471cdb0
commit 7d9300a5e2
6 files changed
+299 -12

No files matched your search

+10 -8
View File
@@ -1,32 +1,34 @@
from services import WeatherInfo
from fabric.utils import invoke_repeater
from fabric.widgets.box import Box
from fabric.widgets.label import Label
from services import WeatherInfo
from snippets import read_config
class Weather(Box):
def __init__(
self,
city: str,
interval: int = 60000,
enable_tooltip=True,
):
super().__init__(name="tray")
self.enable_tooltip = enable_tooltip
self.city = city
self.weather_service = WeatherInfo()
self.weather_label = Label(label="weather")
self.children = self.weather_label
invoke_repeater(interval, self.update_label, initial_call=True)
def update_label(self):
res = self.weather_service.simple_weather_info(city=self.city)
self.weather_label.set_label(f"{res["icon"]} {res["temperature"]}")
config = read_config()
city = config.get("city", "London")
res = self.weather_service.simple_weather_info(city)
self.weather_label.set_label(f"{res['icon']} {res['temperature']}")
if self.enable_tooltip:
self.set_tooltip_text(f"{res["city"]}, {res["condition"]}".strip("'"))
self.set_tooltip_text(f"{res['city']}, {res['condition']}".strip("'"))
return True