class InsertFrame(wx.Frame):
def __init__(self,parent,id):
wx.Frame.__init__(self,parent,id,'Frame With Button',size=(300,100))
panel=wx.Panel(self)
button=wx.Button(panel,label='Close',pos=(125,10),size=(50,50))
self.Bind(wx.EVT_BUTTON,self.OnCloseMe,button)
self.Bind(wx.EVT_CLOSE,self.OnCloseWindow)
def OnCloseMe(self,event):
self.Close(True)
def OnCloseWindow(self,event):
self.Destroy()
if __name__ == '__main__':
app=wx.PySimpleApp()
frame=InsertFrame(parent=None,id=-1)
frame.Show()
app.MainLoop()
大致思路是这样的:面板展开的原理是改变窗口的高度,然后在使得 “服务器”那个面板出现。改变高度使用 self.SetClientSize(wx.Size(a, b))语句,a代表宽度,b代表高度,你只要改变b的值就能控制窗口高度的变化。
“服务器”那个面板出现和隐藏使用self.staticBox1.Show(False),False改成True则该面板出现
示例代码如下:
def OnButton1Button(self, event):
self.SetClientSize(wx.Size(392, 193))
self.staticBox1.Show(False)
event.Skip()
这只是改变大小和可见性的示例,具体你在用到你的软件的时候要修改和添加你需要的东西。
面板收起的原理也是一样的。
如何有不明白的可以再详细询问,希望对能帮到你!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)