Python体验(09)-图形界面之Pannel和Sizer

 

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体验(09)-图形界面之Pannel和Sizer)