TextCtrl fully expanding at program start

A

alex

Hi all
I have a gridsizer consisting of two vertically stacked panels, one
with a StaticBox and the other with a TextCtrl.
I would like that the TextCtrl expands at program start fully to the
allocated panel size (lower panel of gridSizer).
Instead of like now, fully expanding in the width but not exapnding in
the height direction (two lines high).

I am currently running in circles so maybe can anybody help me?
See below for my best effort (OS WinXP, Python 2.5).

Thank you, regards Alex



import wx

class Frame(wx.Frame):
def __init__(self, title, pos, size):
wx.Frame.__init__(self, None, -1, title, pos, size)

self.panel = wx.Panel(self)
self.panel.SetBackgroundColour(wx.Colour(220, 220, 220))

box1 = wx.StaticBox(self.panel, -1, "Program Preferences")
box2 = wx.TextCtrl(self.panel, -1, size=(-1,-1),style =
wx.TE_MULTILINE|wx.TE_READONLY)


gs = wx.GridSizer(2, 1, 0, 0)
windowOneSizer = wx.BoxSizer(wx.VERTICAL)
windowTwoSizer = wx.BoxSizer(wx.VERTICAL)

windowOneSizer.Add(box1, 0, wx.ALL|wx.EXPAND, 0)
windowTwoSizer.Add(box2, 0, wx.ALL|wx.EXPAND, 0)

gs.Add(windowOneSizer, 0, wx.ALL|wx.EXPAND, 2)
gs.Add(windowTwoSizer, 0, wx.ALL|wx.EXPAND, 2)

self.panel.SetSizer(gs)
self.Centre()
self.Show(True)


class App(wx.App):
def OnInit(self):
frame = Frame("My Frame", (100, 100), (400, 250))
frame.Show()
self.SetTopWindow(frame)
return True
#
#
if __name__ == '__main__':
#
app = App()
app.MainLoop()
#
#
 
V

Vlastimil Brom

2009/2/27 alex said:
Hi all
I have a gridsizer consisting of two vertically stacked panels, one
with a StaticBox and the other with a TextCtrl.
I would like that the TextCtrl expands at program start fully to the
allocated panel size (lower panel of gridSizer).
Instead of like now, fully expanding in the width but not exapnding in
the height direction (two lines high). ....

Hi,
changing the proportion for adding the textctrl into the sizer to 1
should expand it to the lower half of the panel.

try changing:
windowTwoSizer.Add(box2, 0, wx.ALL|wx.EXPAND, 0)
TO:
windowTwoSizer.Add(box2, 1, wx.ALL|wx.EXPAND, 0)

See
http://www.wxpython.org/docs/api/wx.Sizer-class.html#Add
for the options for adding into the sizer.

hth
vbr
 
A

alex

...

Hi,
changing the proportion for adding the textctrl into the sizer to 1
should expand it to the lower half of the panel.

try changing:
        windowTwoSizer.Add(box2, 0, wx.ALL|wx.EXPAND, 0)
TO:
        windowTwoSizer.Add(box2, 1, wx.ALL|wx.EXPAND, 0)

Seehttp://www.wxpython.org/docs/api/wx.Sizer-class.html#Add
for the options for adding into the sizer.

hth
   vbr

Hi Vlastimil
I must have overlooked it. Too much reading and trying...
Thank you, it works perfect.

Regards Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top