Merge pull request #288 from ilya-pevzner/on-resize

a minor fix and a build speedup
This commit is contained in:
Aran-Fey
2025-09-27 09:21:02 +02:00
committed by GitHub
3 changed files with 13 additions and 12 deletions

View File

@@ -126,7 +126,7 @@ PYTHONPATH = "."
[[tool.hatch.build.hooks.build-scripts.scripts]]
commands = [
"npm install",
"uvx --with-requirements pyproject.toml python -m scripts.build",
"uvx python -m scripts.build",
]
[tool.ruff]

View File

@@ -431,7 +431,7 @@ class App:
# Nope, get it
try:
icon_blob, _ = await self._icon.fetch_as_bytes()
icon_blob = await self._icon.fetch_as_bytes()
input_buffer = io.BytesIO(icon_blob)
output_buffer = io.BytesIO()
@@ -442,17 +442,17 @@ class App:
self._icon_as_png_blob = output_buffer.getvalue()
# Loading has failed. Use the default icon.
except Exception:
except Exception as e:
if isinstance(self._icon, assets.PathAsset):
logging.error(
f"Could not fetch the app's icon from {self._icon.path.absolute()}"
f"Could not fetch the app's icon from {self._icon.path.absolute()}: {e}"
)
elif isinstance(self._icon, assets.UrlAsset):
logging.error(
f"Could not fetch the app's icon from {self._icon.url}"
f"Could not fetch the app's icon from {self._icon.url}: {e}"
)
else:
logging.error("Could not fetch the app's icon")
logging.error(f"Could not fetch the app's icon: {e}")
assert DEFAULT_ICON_PATH.suffix == ".png", (
"The default icon must be PNG"

View File

@@ -3883,13 +3883,14 @@ a.remove();
"""
Called by the client when a component is resized.
"""
component = self._weak_components_by_id[component_id]
resize_event = rio.ComponentResizeEvent(new_width, new_height)
component = self._weak_components_by_id.get(component_id)
if component:
resize_event = rio.ComponentResizeEvent(new_width, new_height)
for handler, _ in component._rio_event_handlers_[
rio.event.EventTag.ON_RESIZE
]:
self._call_event_handler_sync(handler, component, resize_event)
for handler, _ in component._rio_event_handlers_[
rio.event.EventTag.ON_RESIZE
]:
self._call_event_handler_sync(handler, component, resize_event)
@unicall.local(name="onFullscreenChange")
async def _on_fullscreen_change(self, fullscreen: bool) -> None: