I have a simple script with 2 buttons positioned vertically within a sizer on a panel.

A button-click event attached to the top button changes the height of the top button. However, even though the height of the top button changes, the height of the bottom button does not automatically resize to accomodate the new height of the top button.

Adding self.myboxsizer.Layout() after I change the height of the button does not change the height of the bottom button, but only serves to revert the height of the top button to its original (unmodified) height.

How can I change the height of the top button and automatically resize the height of the bottom button?


import wx

class AFrame(wx.Frame):
    def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, *args, **kwargs)
        self.panel = wx.Panel(self)
        self.button1 = wx.Button(self.panel, 1000, "Button1")
        self.button1.Bind(wx.EVT_BUTTON, self.BtnClick)
        self.button2 = wx.Button(self.panel, 1001, "Button2")
        self.myboxsizer = wx.BoxSizer(wx.VERTICAL)

    def BtnClick(self,event):

if __name__ == '__main__':
    app = wx.App()
    daframe = AFrame(None)

Any assistance will be appreciated. Thank you.

For button1 use : self.myboxsizer.Add(self.button1,0,wx.EXPAND|wx.ALL,30) I works on Windows OS, Linux may behave differently.

Thanks bumsfeld.
Unfortunately the suggestion doesn't work on fedora 6.

Solution discovered with a little help from friends on another post ...

You need to set the minimum size of the button so that the buttons are rendered with the desired dimensions by the controlling sizer on linux:

def BtnClick(self,event):
        newsize = wx.Size(-1,80)

The above displays the buttons correctly on fc6.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.