How do I can have access to a widget dimensions (width, height) in flet (python) at runtime or from other widget in the page? I tried to access to the
widget.width
property directly but I believe it doesn't have read permissions.
How do I can have access to a widget dimensions (width, height) in flet (python) at runtime or from other widget in the page? I tried to access to the
widget.width
property directly but I believe it doesn't have read permissions.
You can set the widget's width/height. Default you can get only the NoneType value.
Example, resize the window's height to change widgets attribute. The widget's value will be moved:
import flet
from flet import Text, Page
def main(page: Page):
label = Text('Resize window\'s height and value of this widget\'s height will be changed!')
label.height = label.height = page.window_height * 0.4
text = Text(label.height)
page.add(label)
page.add(text)
def page_resize(e):
label.height = page.window_height * 0.4
text.value = label.height
label.update()
text.update()
page.on_resize = page_resize
if __name__ == '__main__':
flet.app(target=main)