Search code examples
wxpythonwxwidgets

WxPython AddSpacer


I am trying to add a spacer using WxPython 3.0.1.1 to a wx.GridBagSizer.

If I do the following:

import wx
sizer = wx.GridBagSizer()
sizer.AddSpacer((10,10))

It doesnt work where (10,10) is the size. In the documentation they are mentioning both the Add method and AddSpacer method but none of them seem to work as documented.

I am a bit lost as to what to use to add a spacer to a gridbagsizer, could someone please help?

http://wxpython.org/Phoenix/docs/html/Sizer.html#Sizer.AddSpacer

http://wxpython.org/Phoenix/docs/html/GridBagSizer.html#GridBagSizer.Add

I have looked at the following example: http://nullege.com/codes/search/wx.GridBagSizer.AddSpacer but it does'nt work for me.


Solution

  • It is a grid, so when you are adding things to it, you must tell where to:

    sizer.Add((10, 10), (0, 0))
    

    which adds the spacer of 10x10 into the grid's position (0, 0). (at least in wx 2.8)