More Advanced Grid Layouts
00:00 In this lesson, you will learn how to create more advanced grid layouts. More specifically, this means that you are going to learn how to set up the grid in such a way that a single widget could take up multiple cells, which—when it comes down to it—is a super easy thing to achieve.
00:25 I think that’s going to be helpful. When you use a grid layout and you want to add a widget, at the minimum you have to add three different arguments: the widget, the row, and the column. This is what we have seen in the last video.
And you could even add one more, which would be the alignment, but we are not going to use that in this tutorial. But for the row and the column size, the default value is
1, where the widget is going to take one row and one column.
So this one is going to be a
'Button at (0,0)', so a button in the top left like we have seen before. And this one also only gets
0. Now next to this, I want to have another button that is at column
1. So if run the code now, we should just see two buttons next to each other.
02:18 And we do! This one is working pretty well. But below this, I now want to have another button that is as wide as the two other buttons combined. And for that, let me duplicate this line. And this button, I’m going to rename to a button that spans two cols—two columns. And now we have to set the position first.
I want this one to start at row
1, so below these two buttons. But it should start at column
0, so all the way to the left. And now I have to specify how many rows it’s supposed to occupy and how many columns it’s supposed to occupy.
Become a Member to join the conversation.