resize figure when new controls are added

Brian Blais bblais at bryant.edu
Fri Jun 2 05:40:06 PDT 2006


Hello,

Is there a way to make a figure resize to the optimum size, after a control is added. 
  I tried a simple example, which I post below, but it retains the original minimum 
size, and doesn't expand.


thanks,

			Brian Blais
-- 
-----------------

              bblais at bryant.edu
              http://web.bryant.edu/~bblais

# code which adds one button to a dialog:

from wax import *

class MainFrame(Frame):

     def Body(self):

         self.AddComponent(Button(self, "AAA",self.Doit), stretch=1)
         self.Pack()


     def Doit(self,event):

         m=MyDialog(self,"Hello")
         m.ShowModal()

         print "here"


class MyDialog(CustomDialog):


     def Body(self):

         self.main = Panel(self, direction="VERTICAL")
         self.AddComponent(self.main,expand="both")

         self.main.AddComponent(Button(self.main,"AAA",self.Doit),expand="h")
         self.main.AddComponent(Button(self.main,"BBB",self.Doit),expand="h")


         self.main.Pack()

         self.Pack()

     def Doit(self,event):

         self.main.AddComponent(Button(self.main,"CCC",self.Doit),expand="h")
         self.main.Pack()

         self.Repack()
         print "Yay!"

app = Application(MainFrame, title="A simple editor", direction='vertical')
app.Run()






More information about the wxpython-users mailing list