It seems that sizers dont like me..

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
oshecho
In need of some credit
In need of some credit
Posts: 1
Joined: Wed Mar 02, 2005 9:45 pm

It seems that sizers dont like me..

Post by oshecho » Wed Mar 02, 2005 9:53 pm

Im having problems with using sizers. When I add some things to a grid sizer, it doesnt set the position or change their sizes when the frame expands.
Im guessing that im doing something simple wrong because i'v looked at lots of examples and none of them helped me.
here is the code:

Code: Select all

import wx

[wxID_PANLETTERS, wxID_PANLETTERSCMBTYPE, wxID_PANLETTERSCMDADDLETTER, 
 wxID_PANLETTERSCMDREMOVELETTER, wxID_PANLETTERSLBLEXAMPLE, 
 wxID_PANLETTERSLBLSOUND, wxID_PANLETTERSLBLTYPE, wxID_PANLETTERSLSTLETTERS, 
 wxID_PANLETTERSSTATICTEXT1, wxID_PANLETTERSTXTEXAMPLE, 
 wxID_PANLETTERSTXTSOUND, 
] = [wx.NewId() for _init_ctrls in range(11)]

class panLetters(wx.Frame):
    def _init_coll_gridSizerV_Items(self, parent):
        parent.Add(self.lblType, 1, border=5, flag=wx.EXPAND|wx.ALL)
        parent.Add(self.cmbType, 1, border=5, flag=wx.EXPAND|wx.ALL)
        parent.Add(self.lblSound, 1, border=5, flag=wx.EXPAND|wx.ALL)
        parent.Add(self.txtSound, 1, border=5, flag=wx.EXPAND|wx.ALL)
        parent.Add(self.txtExample, 1, border=5, flag=wx.EXPAND|wx.ALL)
        parent.Add(self.lblExample, 1, border=5, flag=wx.EXPAND|wx.ALL)

    def _init_sizers(self):        
        self.gridSizerV = wx.GridSizer(cols=2, hgap=5, rows=3, vgap=5)

        self._init_coll_gridSizerV_Items(self.gridSizerV)

    def _init_ctrls(self, prnt):
        wx.Frame.__init__(self, id=wxID_PANLETTERS, name='panLetters',
              parent=prnt, pos=wx.Point(397, 283), size=wx.Size(416, 250))
        self.SetClientSize(wx.Size(408, 223))
        self.SetToolTipString('')
        self.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL, False,
              'Microsoft Sans Serif'))

        self.lblType = wx.StaticText(id=wxID_PANLETTERSLBLTYPE, label='Type',
              name='lblType', parent=self, pos=wx.Point(0, 0), size=wx.Size(32,
              16), style=0)

        self.cmbType = wx.Choice(choices=[], id=wxID_PANLETTERSCMBTYPE,
              name='cmbType', parent=self, pos=wx.Point(0, 0), size=wx.Size(88,
              24), style=0)

        self.lblSound = wx.StaticText(id=wxID_PANLETTERSLBLSOUND, label='Sound',
              name='lblSound', parent=self, pos=wx.Point(0, 0), size=wx.Size(39,
              16), style=0)

        self.lblExample = wx.StaticText(id=wxID_PANLETTERSLBLEXAMPLE,
              label='Example', name='lblExample', parent=self, pos=wx.Point(0,
              0), size=wx.Size(53, 16), style=0)

        self.txtSound = wx.TextCtrl(id=wxID_PANLETTERSTXTSOUND, name='txtSound',
              parent=self, pos=wx.Point(0, 0), size=wx.Size(100, 24), style=0,
              value='')

        self.txtExample = wx.TextCtrl(id=wxID_PANLETTERSTXTEXAMPLE,
              name='txtExample', parent=self, pos=wx.Point(0, 0),
              size=wx.Size(100, 24), style=0, value='')

        self._init_sizers()

    def __init__(self, parent):
        self._init_ctrls(parent)
        self.gridSizerV.RecalcSizes()
        
        
class MyApp(wx.App):
    def OnInit(self):
        frame = panLetters(None)
        frame.Show(True)
        self.SetTopWindow(frame)
        return True
    
app = MyApp(0)
app.MainLoop()

Post Reply