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

+2 -3
View File
@@ -8,7 +8,7 @@ from fabric.widgets.datetime import DateTime
from fabric.widgets.wayland import WaylandWindow as Window
from modules.bar.widgets import (
BatteryLabel,
Bluetooth,
Bluetooth, # Weather,
HardwareUsage,
IdleIndicator,
MicrophoneIndicator,
@@ -16,7 +16,6 @@ from modules.bar.widgets import (
PowerProfile,
TaskBar,
VolumeIndicator,
Weather,
workspace,
)
@@ -56,7 +55,7 @@ class Bar(Window):
self.workspaces = Button(child=workspace, name="workspaces")
self.info = HardwareUsage()
self.idle = IdleIndicator()
self.weather = Weather("Kohalpur")
# self.weather = Weather()
self.applets = Box(
name="applets",
spacing=4,
+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