I’ve attached your code with minor tweaks, compare with the original to see what I changed. I think the root of your problem is that you have nested sizers you do not think that they need to be set to expand or to have a proportion value too. If the nested sizer can’t expand then the items within it can’t either.
–
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
#!/usr/bin/env python
“”“SizerTest - 'cause Sizer’s wx.EXPAND does not GROW “””
import wx
print wx.version()
class SizerTest(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, parent = None, id = wx.ID_ANY)
pn = wx.Panel(self)
mainsizer = wx.BoxSizer(wx.VERTICAL)
pn.SetSizer(mainsizer)
firstsizer = wx.BoxSizer(wx.HORIZONTAL)
mflag = wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.GROW
for i in range(6):
firstsizer.Add(wx.Button(pn, wx.ID_ANY, label = str(i),\
size = (30, 30)), 0, flag = mflag, border = 2)
mainsizer.Add(firstsizer, 0, wx.EXPAND)
text = wx.TextCtrl(pn, wx.ID_ANY, 'Stretta la foglia larga la via', \
) #size = (600, wx.ID_ANY))
mainsizer.Add(text, 0, wx.EXPAND|wx.ALL , 3)
secondsizer = wx.BoxSizer(wx.VERTICAL)
secondsizer.Add(text, 0, wx.ALL , 3)
mainsizer.Add(secondsizer, 0, wx.ALL , 3)
(even this second solution does not work)
# now the problen
boxv = wx.BoxSizer(wx.VERTICAL)
boxh = wx.BoxSizer(wx.HORIZONTAL)
boxh.Add(wx.StaticText(pn, wx.ID_ANY, 'test: '), 0, wx.CENTER, 2)
choice = wx.Choice(pn, wx.ID_ANY, size = (200, wx.ID_ANY))
boxh.Add(choice, 1, wx.ALIGN_RIGHT |wx.ALL |wx.EXPAND , 2)
boxv.Add(boxh,0, wx.EXPAND)
shortertext = wx.TextCtrl(pn, wx.ID_ANY, 'Dite la vostra che ho detto la mia', \
size = (300, wx.ID_ANY))
boxv.Add(shortertext, 0, wx.EXPAND)
firstsizer.Add(boxv, 1, wx.EXPAND)
self.Layout()
mainsizer.Layout()
mainsizer.Fit(pn)
self.Fit()
Comment:
In my intention, choice and shortertext should grow until their right
size is in the same x position as the righ side of text.
Note that if you resize the frame, the windows sizes do not change
if name == ‘main’:
app = wx.App()
frame = SizerTest()
frame.Show(True)
import wx.lib.inspection
wx.lib.inspection.InspectionTool().Show()
app.MainLoop()
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users