[Q] wxPython - layout & placement

Robert Amesz sheershion at mailexpire.com
Fri Jul 19 19:39:08 EDT 2002


Rolf Marvin Bøe Lindgren wrote:

> I'm trying to place a button in a dialog window.  this works:
> 
>         dlg = wxDialog(parent,-1,FileName,size=(400,400))
> 
>         wxButton (parent=dlg,
>                   id = -1,
>                   label = 'This is a button',
>                   pos=(10,10))
> 
>         dlg.ShowModal()
> 
> but I'd like to use layout controls.  I've figured out how to do it
> with wxPanel, but wxDialog doesn't seem to work the same way.  the
> example on <URL:http://www.wxpython.org/tut-part2.php> 
> 
>         b = wxButton(self.panelA, 100, ' Panel A ')
>         lc = wxLayoutConstraints()
>         lc.centreX.SameAs (self.panelA, wxCentreX)
>         lc.centreY.SameAs (self.panelA, wxCentreY)
>         lc.height.AsIs ()
>         lc.width.PercentOf (self.panelA, wxWidth, 50)
>         b.SetConstraints(lc)
> 
> does not work if the parent object is a wxDialog. 
> 
> any clues?  
> 
> 

Hmmm, puzzling... But then, there's a lot of code which you aren't 
showing. What, for instance, is panelA (and why do you use it), things 
like that.

But you'd better forget about wxLayoutConstraints altogether. The 
manual states:

   Note: constraints are now deprecated and you should use sizers
   instead. 

Don't worry: sizers are pretty easy to use. Nearly always easier than 
using constraints.


Robert Amesz




More information about the Python-list mailing list