The resizing problem comes from your Fit(). They are not necessary. You
do not need to Refresh() or Update() either.
When you add or remove a widget in a sizer, you have to call Layout()
after that.
I modified your function onclick this way:
def onclick(self, event):
b = wxButton(self.panel, -1, "Button")
self.sizer2.Add(b, 1 ,wxEXPAND)
#self.sizer2.Fit(self.panel)
#self.sizer1.Fit(self)
self.sizer2.Layout()
## self.Refresh()
## self.Update()
···
-----Original Message-----
From: Martin.Zohlhuber@tttech.com [mailto:Martin.Zohlhuber@tttech.com]
Sent: Friday, March 12, 2004 5:26 PM
To: wxPython-users@lists.wxwidgets.org
Subject: [wxPython-users] How notify something has changed ?
Hello
I am newbie and the sizer in wx make me a little bit crazy.
I made a small example (see below) with a GridSizer with 3 Buttons and a
Panel. The panel contain a button and when it clicked, i add a new
button
in the panel. The Problem: The new button will not displayed. When i am
resize i see the two buttons.
Whats wrong in my example ? How notify the frame, something has changed
inside ?
Second strange behaviour: when i click the button again after a
resize,
the box get smaller (old size). What's wrong ?
I have the similar problem, when i hide a Widget (i get a hole).
I have also a few general questions about wx:
* Can i emit Events ?
Event are connected by:
EVT_XXX(ID, Function).
* How can i send my own parameter to the callbackfunction ? The most
examples use classwide defined variables (self.xyz) , but what do from
outside ?
Thanks
martin
---------------------------------------------------------
from wxPython.wx import *
buttonlist = []
class myframe1(wxFrame):
def __init__(self, parent = None, id = -1, index= ""):
wxFrame.__init__(self, parent, id, "hello" + index,
style=wxDEFAULT_FRAME_STYLE
> wxNO_FULL_REPAINT_ON_RESIZE)
self.sizer1 = wxGridSizer(2)
button1 = wxButton(self, -1, "Button1" + index)
self.sizer1.Add(button1, 1 ,wxEXPAND)
button3 = wxButton(self, -1, "Button3" + index)
self.sizer1.Add(button3, 1 ,wxEXPAND)
button4 = wxButton(self, -1, "Button4" + index)
self.sizer1.Add(button4, 1 ,wxEXPAND)
self.but2id = wxNewId()
self.panel = wxPanel(self, -1)
self.sizer2 = wxBoxSizer(wxVERTICAL)
self.button2 = wxButton(self.panel, self.but2id, "Click Button2"
+
index)
self.sizer2.Add(self.button2, 1 ,wxEXPAND)
self.panel.SetSizerAndFit(self.sizer2)
EVT_BUTTON(self, self.but2id, self.onclick)
self.sizer1.Add(self.panel, 1 ,wxEXPAND)
self.SetSizer(self.sizer1)
self.SetAutoLayout(1)
self.Fit()
self.Show(1)
def onclick(self, event):
b = wxButton(self.panel, -1, "Button")
self.sizer2.Add(b, 1 ,wxEXPAND)
self.sizer2.Fit(self.panel)
self.sizer1.Fit(self)
self.Refresh()
self.Update()
def _test():
app = wxPySimpleApp()
m = myframe1()
app.MainLoop()
if __name__ == "__main__" :
_test ()
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org