2005年11月19日 星期六 16:37
Hi, sorry for my chinese input method doesn' t work now. I'd like to delete and add some controls on wxPanel dynamically. I use wxSizer.Detach() and Layout(), but it doesn't work at all, as the following code shows. If the control(say self.btn) in sizer has nonzero proportion, it works fine. But I wish the button stays non-expand, any way ? or any wrong usage of sizer? Zhang -------------------------------------------------------- import wx class Form1(wx.Panel): def __init__(self,parent,id): wx.Panel.__init__(self,parent,id) self.btn = wx.Button(self, -1, 'go') self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.btn) ## it doesn't work # self.sizer.Add(self.btn, 1) ## it works self.p1 = wx.StaticText(self, -1, 'ppp1') self.sizer.Add(self.p1) self.SetSizer(self.sizer) self.SetAutoLayout(True) self.btn.Bind(wx.EVT_BUTTON, self.onbtn) def onbtn(self,event): self.sizer.Detach(self.p1) self.sizer.Layout() app = wx.PySimpleApp() frame = wx.Frame(None, -1, "Test") Form1(frame,-1) frame.Show(1) app.MainLoop()
2005年11月19日 星期六 19:38
zhang yunfeng wrote: > Hi, sorry for my chinese input method doesn' t work now. > > I'd like to delete and add some controls on wxPanel dynamically. I use > wxSizer.Detach() and Layout(), but it doesn't work at all, as the > following code shows. If the control(say self.btn) in sizer has nonzero > proportion, it works fine. But I wish the button stays non-expand, any > way ? or any wrong usage of sizer? > [略] > def onbtn(self,event): > self.sizer.Detach(self.p1) 在这里加上 self.p1.Destroy() > self.sizer.Layout() [略] -- Qiangning Hong, Registered Linux User #396996 My Blog: http://www.hn.org/hongqn RSS: http://feeds.feedburner.com/hongqn
2005年11月20日 星期日 15:22
多谢,好用了,只是看起来有点儿闪动,有什么办法解决吗? 2005/11/19, Qiangning Hong <hongqn at gmail.com>: > zhang yunfeng wrote: > > Hi, sorry for my chinese input method doesn' t work now. > > > > I'd like to delete and add some controls on wxPanel dynamically. I use > > wxSizer.Detach() and Layout(), but it doesn't work at all, as the > > following code shows. If the control(say self.btn) in sizer has nonzero > > proportion, it works fine. But I wish the button stays non-expand, any > > way ? or any wrong usage of sizer? > > > [略] > > def onbtn(self,event): > > self.sizer.Detach(self.p1) > > 在这里加上 self.p1.Destroy() > > > self.sizer.Layout() > > [略] > >
Zeuux © 2025
京ICP备05028076号