Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8112d4e

Browse files
committed
fix(weather): improve icon handling in WeatherWidget
- Ensure icons are only replaced from the dictionary if they exist.- Default icon is set correctly based on conditions.
1 parent7dcc8fb commit8112d4e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

‎src/core/widgets/yasb/weather.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@ def _update_label(self,update_class=True):
314314
ifisinstance(active_widgets[widget_index],QLabel):
315315
if'<span'inpartand'</span>'inpart:
316316
icon=re.sub(r'<span.*?>|</span>','',part).strip()
317-
icon=self._icons.get(icon,self._icons["default"])
317+
# Only replace with icons dictionary if the content is actually in the dictionary
318+
ificoninself._icons:
319+
icon=self._icons.get(icon)
318320
active_widgets[widget_index].setText(icon)
319321
ifupdate_class:
320322
# Retrieve current class and append new class based on weather conditions
@@ -393,6 +395,13 @@ def get_weather_data(self, api_url):
393395
conditions_data="snowyIcy"
394396
icon_string=f"{conditions_data}{'Day'ifcurrent['is_day']==1else'Night'}".strip()
395397

398+
ificon_string:
399+
icon_label=self._icons["default"]
400+
ificon_labelnotinself._icons:
401+
icon_label=self._icons["default"]
402+
else:
403+
icon_label=self._icons["default"]
404+
396405
# Load icons into cache for current and future forecasts if not already cached
397406
# We will try to load the images for 1sec, if it fails we will try again when popup is opened
398407
img_icon_keys= [f'http:{day["condition"]["icon"]}'fordayin [forecast]+ [forecast1["day"],forecast2["day"]]]
@@ -428,7 +437,7 @@ def get_weather_data(self, api_url):
428437
'{is_day}':current['is_day'],
429438

430439
# Icons
431-
'{icon}':icon_string[0].lower()+icon_string[1:],
440+
'{icon}':icon_label,
432441
'{icon_class}':icon_string[0].lower()+icon_string[1:],
433442
'{day0_icon}':f'http:{forecast["condition"]["icon"]}',
434443

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp