Changing button size at run-time

Acolyte jmaxwell at aapt.net.au
Fri Feb 16 09:49:17 PST 2007


Hello,

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?

(I am using fedora 6, python 2.4 and wxpython 2.8)

|
#!/usr/bin/python


import wx


class AFrame(wx.Frame):
	def __init__(self, *args, **kwargs):
		wx.Frame.__init__(self, *args, **kwargs)
		=

		self.SetSize(wx.Size(300,400))
		=

		self.panel =3D wx.Panel(self)
		self.button1 =3D wx.Button(self.panel, 1000, "Button1")
		self.button1.Bind(wx.EVT_BUTTON, self.BtnClick)
		=

		self.button2 =3D wx.Button(self.panel, 1001, "Button2")
		=

		self.myboxsizer =3D wx.BoxSizer(wx.VERTICAL)
		self.myboxsizer.Add(self.button1,0,wx.EXPAND|\
							wx.TOP|wx.LEFT|wx.RIGHT,30)
		self.myboxsizer.Add(self.button2,1,wx.EXPAND|\
							wx.ALL,30)
		=

		self.panel.SetSizer(self.myboxsizer)

	def BtnClick(self,event):
		self.button1.SetSize(wx.Size(-1,80))
		#self.myboxsizer.Layout()
	=



if __name__ =3D=3D '__main__':
	app =3D wx.App()
	daframe =3D AFrame(None)
	daframe.Show()
	app.MainLoop()
	=


|

Any assistance will be appreciated. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200702=
17/5833dcfc/attachment.htm


More information about the wxpython-users mailing list