Skip to content Skip to sidebar Skip to footer

Layout Management With Wxpython

This new question is build on this I am having problem with managing the layout in wxPython. In this program I have two buttons in two layouts. But no matter what I do I cant chan

Solution 1:

  1. To get this button to be positioned in the centre just use the flag wx.CENTER. You also need to set this sizer to as the panels sizer.

    self.moduleSizer = wx.BoxSizer(wx.VERTICAL)
    self.button1 = wx.Button(self.modulePanel, label="Show Yellow Panel",
                             size=(200, -1))
    self.moduleSizer.Add(self.button1, flag=wx.CENTER)
    self.modulePanel.SetSizer(self.moduleSizer)
    
  2. To get this button positioned on the left with an indent of 20 use the flag wx.Left and set the border as 20. As above you also need to set this sizer to its panel.

    self.TCSizer = wx.BoxSizer(wx.VERTICAL)
    self.button2 = wx.Button(self.TCPanel, label="Bring Black Panel",
                             size=(200, -1))
    self.TCSizer.Add(self.button2, flag=wx.LEFT, border=20)
    self.TCPanel.SetSizer(self.TCSizer)
    

At the end of you init method call.

self.Layout()

to get the sizers to update themselves.

Post a Comment for "Layout Management With Wxpython"