how to set the width and height of an ui.image in nicegui?

37 Views Asked by At

I want to migrate some justpy code to nicegui. While the justpy IMG class could set with and height in the constructor the natural way to migrate would be:

with topicHeader:
                _topicIcon = ui.image(
                    source=icon_url,
                    width=f"{self.iconSize}",
                    height=f"{self.iconSize}",
                )

but nicegui does not have width and height. I looked in the source code:

class Image(SourceElement, component='image.js'):
    PIL_CONVERT_FORMAT = 'PNG'

    def __init__(self, source: Union[str, Path, 'PIL_Image'] = '') -> None:
        """Image

        Displays an image.
        This element is based on Quasar's `QImg <https://quasar.dev/vue-components/img>`_ component.

        :param source: the source of the image; can be a URL, local file path, a base64 string or a PIL image
        """
        super().__init__(source=source)

and the constructor only supports the source parameter. Similar to How to set the width of a ui.input i would assume i have to set props for width and height but i did't find an example.

0

There are 0 best solutions below