Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace item in wxPython GridSizer

I have a wx.Frame with a wx.GridSizer. This grid contains several custom wx.Panel. I need to swap the content of two cells of my grid. I tried several solutions using Detach, GetItem, and Insert methods without success.

For example suppose I have a 3x3 grid with 8 elements (my custom panels) from 0 to 7. In this case the last cell of the grid is empty. I want to move the last item (grid[7]) in the last cell (grid[8]).

How can I do? And what are the differences if the last the last cell is not empty?

like image 303
Nick Avatar asked Apr 13 '26 21:04

Nick


1 Answers

'panelInGrid7' in the following is the instance of your panel which is in grid[7], in gridBagSizer positions this would be in (2, 1)

sizer.Detach(panelInGrid7)
sizer.Add(panelInGrid7, (2,3))

If (2, 3) is not empty you would need to detach that item too and then add it to where you want it.

like image 137
Werner Avatar answered Apr 16 '26 09:04

Werner