List Info

Thread: How to fill a panel with a control




How to fill a panel with a control
user name
2007-06-27 18:10:46
I have a radio box in a panel. I want the radio box to cover the whole panel. How do I do that? Here's what I am dong.

self.panel1 = wx.Panel(self,-1)

self.radiobox1 = wx.RadioBox(self.panel1, -1, "Radio box test", choices = ["Yes", "no", "Dont care"])

panel1sizer = wx.BoxSizer(wx.Horizontal)

panel1seizer.Add(self.radiobox1)
self.panel1.SetSizer(panel1sizer)

Thanks in advance,

Ananda


Re: How to fill a panel with a control
user name
2007-06-27 18:25:54


On 6/27/07, Ananda Regmi < aregmigmail.com">aregmigmail.com> wrote:
I have a radio box in a panel. I want the radio box to cover the whole panel. How do I do that? Here's what I am dong.

self.panel1 = wx.Panel(self,-1)

self.radiobox1 = wx.RadioBox(self.panel1, -1, "Radio box test", choices = ["Yes", "no&quot;, "Dont care"])

panel1sizer = wx.BoxSizer(wx.Horizontal)

panel1seizer.Add(self.radiobox1)
self.panel1.SetSizer(panel1sizer)

Thanks in advance,

Ananda

Change to:

panel1sizer.Add(self.radiobox1, proportion=1, flag=wx.EXPAND)

... and if you need some border space around the panel, change the parameters as follows:

flag=wx.EXPAND | wx.ALL, border=4

(replace 4 with the pixel width of the desired border).

The documentation for wx.Sizer.Add() covers these options.&nbsp; Most important is to note that the "proportion"; parameter controls whether the item added to the sizer is allowed to expand in the sizer's primary direction (in this case, wx.HORIZONTAL), while the wx.EXPAND flag relates only to allowing the item to expand in the other direction.

Also, you may need to call self.panel1.Layout() or possibly self.Layout() in order to actually cause the sizer to do its work at a particular time.

Cheers,
Eric
 


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )