开发者社区 问答 正文

python中panel怎么用

python中panel怎么用

展开
收起
云计算小粉 2018-05-10 20:10:59 5800 分享 版权
1 条回答
写回答
取消 提交回答
  •  Panel是窗口的容器,通常其大小与Frame一样,在其上放置各种控件,这样可将窗口内容与工具栏及状态栏区分开,能过TAB键可遍历Panel中的元素,直接看个例子:

    #!/usr/bin/env python
    # -- coding: utf-8 --

    import wx

    class MyFrame(wx.Frame):

    
    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, u'测试面板Panel', size = (600, 300))
        
        #创建面板
        panel = wx.Panel(self) 
        
        #在Panel上添加Button
        button = wx.Button(panel, label = u'关闭', pos = (150, 60), size = (100, 60))
        
        #绑定单击事件
        self.Bind(wx.EVT_BUTTON, self.OnCloseMe, button)
        
    def OnCloseMe(self, event):
        self.Close(True)
    

    if name == '__main__':

    app = wx.PySimpleApp()
    frame = MyFrame(parent = None, id = -1)
    frame.Show()
    app.MainLoop()
    
    2019-07-17 22:24:19
    赞同 展开评论
问答分类:
问答地址: