如何在NiceGUI中设置ui.image的宽度和高度?
我想把一些justpy的代码迁移到nicegui。虽然在justpy中,IMG类可以在构造函数里设置宽度和高度,但迁移的自然方式应该是:
with topicHeader:
_topicIcon = ui.image(
source=icon_url,
width=f"{self.iconSize}",
height=f"{self.iconSize}",
)
但是nicegui并没有宽度和高度的设置。我查看了源代码:
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)
发现构造函数只支持源参数。类似于如何设置ui.input的宽度,我猜我需要为宽度和高度设置属性,但我没有找到相关的例子。
1 个回答
暂无回答