[wxPython-users] Layout witout resize don't work ?

Oswaldo Hernández listas at soft-com.es
Sun Jul 1 03:58:04 PDT 2007


Robin Dunn escribió:
> Oswaldo Hernández wrote:
>> Hello all,
>>
>> On a Frame I want show/hide a label. To do it, i create a label on 
>> __init__, put on the ziser and hide it.
>>
>> When i need show the label i do:
>> self.label.Show()
>> self.Layout()
>>
>> But the label is showed in top/left corner.
>> I suppose that the layout do not the work because the window size do 
>> not change.
>> If resize the window with the mouse, the label is moved to the proper 
>> position.
> 
> 
> When you call self.Layout that results in a call to the frame's sizer's 
> Layout method.  Since the only thing in that sizer is the main panel, 
> and since the panel is not changing size, then the layout process stops 
> there.  On the other hand when you change the size of the frame then the 
> size of the panel changes too and so its sizer's Layout is called and 
> since it contains the label then it is positioned where you want it to be.
> 
> So to solve your problem don't call the frame's Layout, but he panel's. 
>  You you can also do it by asking the label for the sizer that contains 
> it and then call Layout there, so:
> 
>     self.panel.Layout()
> 
> or:
> 
>     self.label_msg.GetContainingSizer().Layout()
> 

Anohter lesson about sizers :)

Thanks Robin.

-- 
*****************************************
Oswaldo Hernández
oswaldo (@) soft-com (.) es
*****************************************




More information about the wxpython-users mailing list