Orjanp
Orjanp

Reputation: 10921

Set the size of wx.GridBagSizer dynamically

I'm creating an app where I drag button widgets into a panel. I would like to have a visible grid in the panel where i drop the widgets so the widgets will be aligned to the grid.

I guess it isn't hard making a grid where the squares are 15x15 pixels using a GridBagSizer(since the widgets will span between multiple cells), but how can the number of squares be made dynamically according to the size of the panel?

Do I have to calculate how many squares i need to fill the panel on init and on each resize?

Using python and wxpython btw.

Oerjan Pettersen

Upvotes: 1

Views: 1014

Answers (1)

user9876
user9876

Reputation: 11102

Don't use a sizer at all for this. Just position the buttons yourself, with whatever co-ordinate rounding you like. (using wxWindow::SetSize()).

(The point of a sizer is that the buttons will get moved and/or resized when the window is resized. As you don't want that behaviour, then you shouldn't use a sizer.)

Upvotes: 1

Related Questions