Jump to content
  • Advertisement
Sign in to follow this  

wxPython, problem with wxSplitterWindow

This topic is 4874 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, This question is most likely equally applied to wxWidgets. I have something like this
		self.splitter = wxSplitterWindow(self , -1)
		self.sidebar_objprop = wxWindow(self.splitter , -1 , style = wxSIMPLE_BORDER)
		self.tree = wxTreeCtrl(self.splitter,-1)
		l = layoutf.Layoutf("l=l2#1;r=l2#2;t=t2#2;b=b2#2",(self,self.glcanvas))
		self.splitter.SplitHorizontally(self.sidebar_objprop , self.tree)
		b = wxButton(self.sidebar_objprop , -1 , "New Keyframe" , (150,40))
		b.SetConstraints(layoutf.Layoutf("X=X#1;Y=Y#1;h*;w%w75#1" , (self.sidebar_objprop,)))

The button is off centered going outside the edge of the wxWindow. If I do this the button's center should be centered inside sidebar_objprop right? It is ignoring the layout and using the position... why? Thanks. [Edited by - Genjix on November 20, 2005 9:31:27 AM]

Share this post

Link to post
Share on other sites
maybe that helps

the centre function centers a window relative to the top windows position

void Centre(int direction = wxBOTH)

Centres the window.



Specifies the direction for the centering. May be wxHORIZONTAL, wxVERTICAL or wxBOTH. It may also include wxCENTRE_ON_SCREEN flag if you want to center the window on the entire screen and not on its parent window.
The flag wxCENTRE_FRAME is obsolete and should not be used any longer (it has no effect).


If the window is a top level one (i.e. doesn't have a parent), it will be centered relative to the screen anyhow.

See also


Share this post

Link to post
Share on other sites
strange... if I use b.Center(wxHORIZONTAL) it snaps to (0,0) of that panel... any other clues why my layouts are being ignored yet position is not?

Share this post

Link to post
Share on other sites
Could you tell use what your layout.Layoutf(...) does? is it a custom class of yours or is it provided by the wxwidegets library

One thing I found in the wxhelp

is wxIndividualLayoutConstraint

However under wxLayoutConstraints it says constraints are now deprecated and you should use wxSizer instead

Share this post

Link to post
Share on other sites
oh... it doesn't look like wxPython.lib.layoutf.Layoutf is included in wxWidgets.
This is an extremely useful lib for specifying positioning of panels..


Quick Example:

lc = Layoutf('t=t#1;l=r10#2;r!100;h%h50#1', (self, self.panel))

is equivalent to

lc = wxLayoutContraints()
lc.top.SameAs(self, wxTop)
lc.left.SameAs(self.panel, wxRight, 10)
lc.height.PercentOf(self, wxHeight, 50)


Constraint directives are separated by semi-colons. You
generally (always?) need four directives to completely describe a
subwindow's location.

A single directive has either of the following forms:

1. <own attribute><compare operation>[numerical argument]
for example r!100 -> lc.right.Absolute(100) )
and w* -> lc.width.AsIs()

2. <own attribute><compare operation>[numerical argument]
#<compare object nr.>
for example t_10#2 (lc.top.Below(<second obj>, 10)

3. <own attribute><compare operation><compare attribute>
[numerical argument]#<compare object nr.>
for example w%h50#2 ( lc.width.PercentOf(<second obj>,
wxHeight, 50) and t=b#1 ( lc.top.SameAs(<first obj>,
wxBottom) )

Which one you need is defined by the <compare operation>
type. The following take type 1 (no object to compare with):

'!': 'Absolute', '?': 'Unconstrained', '*': 'AsIs'

These take type 2 (need to be compared with another object)

'<': 'LeftOf', '>': 'RightOf', '^': 'Above', '_': 'Below'

These take type 3 (need to be compared to another object

'=': 'SameAs', '%': 'PercentOf'

For all types, the <own attribute> letter can be any of

't': 'top', 'l': 'left', 'b': 'bottom',
'r': 'right', 'h': 'height', 'w': 'width',
'x': 'centreX', 'y': 'centreY'

If the operation takes an (optional) numerical argument, place it
in [numerical argument]. For type 3 directives, the <compare
attribute> letter can be any of

't': 'wxTop', 'l': 'wxLeft', 'b': 'wxBottom'
'r': 'wxRight', 'h': 'wxHeight', 'w': 'wxWidth',
'x': 'wxCentreX', 'y': 'wxCentreY'

so in my layout for the button

"X=X#1;Y=Y#1;h*;w%w75#1" , (self.sidebar_objprop,)

=> X = X #1
Y = Y #1
w %w75 #1

where #1 = self.sidebar_objprop

this translates as
center of button's X is center of #1's X
center of button's Y is center of #1's Y
height as is
width is 75% of #1's width

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!