Dynamically change the size of a widget


I have two widgets, one to left and one to the right. If a user presses a button, I want to increase the widget on the left.

So I added an action:

async def on_load(self, event):
        await self.bind("q", "quit", "Quit")
        await self.bind("e", "extend", "Extend panel")

async def action_extend(self):
        self.left_widget.animate("layout_size", 100)

However, this causes a TypeError: can't multiply sequence by non-int of type 'float'

Is there any other way of changing the size?


Found an answer. You can’t animate it.

But, if you just set the value it changes it, too.

async def action_extend(self):
        self.left_widget.layout_size = 100

However, it would be nice if layout_size can also be animated.

Just an idea, didn’t try this, but what if you would also animate the right widget in the other direction, or make it smaller so the left widget has room to perform the animate.