Skip to content

Commit e1c13bc

Browse files
committed
fix: fix re-rendering TGP images
1 parent e79741f commit e1c13bc

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

textual_image/widget/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def image(self, value: StrOrBytesPath | IO[bytes] | PILImage.Image | None) -> No
103103
self._image_width = 0
104104
self._image_height = 0
105105

106-
self.refresh(layout=True, recompose=True)
106+
self.refresh(layout=True)
107107

108108
@override
109109
def render(self) -> RenderResult:

textual_image/widget/sixel.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class _NoopRenderable:
5454
"""Image renderable rendering nothing.
5555
5656
Used by the Sixel image as placeholder.
57-
Rendering the Sixel renderable doesn't work with Textual as it relies printable segments.
57+
Rendering the Sixel renderable doesn't work with Textual as it relies on printable segments.
5858
Instead, Sixel data is injected into the rendering process. To keep our base class happy, we use this class
5959
as renderable passed to it.
6060
"""
@@ -80,6 +80,12 @@ def cleanup(self) -> None:
8080
class Image(BaseImage, Renderable=_NoopRenderable):
8181
"""Textual `Widget` to render images as Sixels (<https://en.wikipedia.org/wiki/Sixel>) in the terminal."""
8282

83+
@override
84+
@BaseImage.image.setter # type: ignore
85+
def image(self, value: StrOrBytesPath | IO[bytes] | PILImage.Image | None) -> None:
86+
super(__class__, type(self)).image.fset(self, value) # type: ignore
87+
self.refresh(recompose=True)
88+
8389
def compose(self) -> ComposeResult:
8490
"""Called by Textual to create child widgets."""
8591
yield _ImageSixelImpl(self.image)

0 commit comments

Comments
 (0)