码迷,mamicode.com
首页 > 编程语言 > 详细

Python体验(08)-Pannel和Sizer

时间:2016-03-21 00:15:52      阅读:289      评论:0      收藏:0      [点我收藏+]

标签:

 

import wx
class Form(wx.Frame):
    def __init__(self,parent,ID,title):
        wx.Frame.__init__(self,parent,ID,title)
        panel = wx.Panel(self,-1)

        wx.Button(panel,-1,"Button1",(0,0))
        wx.Button(panel,-1,"Button2",(80,0))
        wx.Button(panel,-1,"Button3",(160,0))

class App(wx.App):
    def OnPreInit(self):
        form = Form(None,-1,"Panel Layout")
        form.Show()
        form.Centre()

app = App()
app.MainLoop()

 

import wx
class MyFrame( wx.Frame ):  
    def __init__( self, parent, id, title ):
        wx.Frame.__init__( self, parent, id, title )
        pnl1 = wx.Panel( self, -1, style=wx.SIMPLE_BORDER )
        pnl2 = wx.Panel( self, -1, style=wx.RAISED_BORDER )
        pnl3 = wx.Panel( self, -1, style=wx.SUNKEN_BORDER )
        pnl4 = wx.Panel( self, -1, style=wx.DOUBLE_BORDER )
        pnl5 = wx.Panel( self, -1, style=wx.STATIC_BORDER )
        pnl6 = wx.Panel( self, -1, style=wx.NO_BORDER )

        hbox1 = wx.BoxSizer( wx.HORIZONTAL )
        hbox1.Add( pnl1, 1, wx.EXPAND | wx.ALL, 3 )
        hbox1.Add( pnl2, 1, wx.EXPAND | wx.ALL, 3 )
        hbox1.Add( pnl3, 1, wx.EXPAND | wx.ALL, 3 )
        hbox2 = wx.BoxSizer( wx.HORIZONTAL )
        hbox2.Add( pnl4, 1, wx.EXPAND | wx.ALL, 3 )
        hbox2.Add( pnl5, 1, wx.EXPAND | wx.ALL, 3 )
        hbox2.Add( pnl6, 1, wx.EXPAND | wx.ALL, 3 )
        vbox=wx.BoxSizer(wx.VERTICAL)
        vbox.Add( hbox1, 1, wx.EXPAND )
        vbox.Add( hbox2, 1, wx.EXPAND )
        self.SetSizer( vbox )
        self.Centre()

class MyApp( wx.App ):  
    def OnInit( self ):
        frame = MyFrame( None, -1, borders.py )
        frame.Show( True )
        return True

app = MyApp()
app.MainLoop()  

 

Python体验(08)-Pannel和Sizer

标签:

原文地址:http://www.cnblogs.com/flaaash/p/5300259.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!