Inserting items into GridBagSizer

Is there any way of inserting an item into the wx.GridBagSizer by an (x, y) point of the parent panel? I know there is a [FindItemAtPoint](http://www.wxpython.org/docs/api/wx.GridBagSizer-class.html#FindItemAtPoint)(self , pt)
] is there some way of doing a setItemAtPoint.

···


“A government big enough to give us everything we want is a government big enough to take from us everything we have.”
-Gerald Ford

Hello,

···

On Mon, Jul 27, 2009 at 2:30 PM, Joshua Huber<jlhuber2@gmail.com> wrote:

Is there any way of inserting an item into the wx.GridBagSizer by an (x, y)
point of the parent panel? I know there is a FindItemAtPoint(self, pt) ] is
there some way of doing a setItemAtPoint.

Yes, use the 'Insert' method. It works just as the Add method, items
are stored in the sizer like an array so you will need to convert your
(x,y) cords to the appropriate 0 based index in the sizer.

Cody

Joshua Huber wrote:

Is there any way of inserting an item into the wx.GridBagSizer by an (x, y) point of the parent panel? I know there is a ||FindItemAtPoint| <wxPython API Documentation — wxPython Phoenix 4.2.2 documentation(self, pt)| ] is there some way of doing a setItemAtPoint.

It shouldn't be too hard to calculate the cell position that the (x,y) lies in. The sizer has GetRowHeights and GetColWidths methods that return lists of integers. Just traverse the list summing widths or heights until you find the one whose beginning is <= the x or y and whose end is > the x or y.

Once you have the cell position then you can do a normal Add to put an item there.

···

--
Robin Dunn
Software Craftsman