Reputation: 2438
Is there anything you can use to add space around the edges of a window or between components with wxWidgets/wxPython? I want something to prevent components from being squished up against the window border or each other, similar to what can be done with Java Swing's EmptyBorder or Insets. (I know you can set horizontal/vertical gaps with some sizers, but I'd like something more flexible.)
Upvotes: 2
Views: 2380
Reputation: 814
I haven't tried it on python but in c++, accepted answer didn't work. I had to use 'AddSpaceer' as:
mySizer->AddSpacer((10, 10));
Upvotes: 0
Reputation: 33071
See the border parameter in the Sizer's Add method. You can use the flag parameter to tell it where to put the border, such as wx.ALL, wx.RIGHT, wx.LEFT, wx.TOP, etc.
This can be used to put space around widgets and between widgets. Sometimes you might want to use the sizer's AddSpacer to add space. Or you can just do something like this:
mySizer.Add((20, 100))
What that does is put 100 pixels between two widgets on the y axis. You'll probably have to play with it a bit to get it the way you want.
See also http://wiki.wxpython.org/GridSizerTutorial or http://zetcode.com/wxpython/layout/
Upvotes: 1
Reputation: 20457
The sizers provided by wxWidgets are very flexible. Are you sure you have explored all that they are capable of? It is hard to imagine what you might need that they cannot handle. Please describe exactly what you need and post the code which you have tried so far.
Here is an example:
sizer->Add(new wxButton(this, -1, "Button with 20 pixel border all round"),
0, wxALL, 20);
Here is a demo of more sizer options. http://neume.sourceforge.net/sizerdemo/
If you really cannot use sizers to achieve what you need, then you can explicitly position each widget wherever you want by passing in a location to the widget constructor.
wxPoint button_position( 50,50 ); // position button 50 pixel down and to right of top left
new wxButton(this, -1, "Button", button_position )
Upvotes: 2