gridbagsizer

#coding:utf-8
import wx

labels='1 2 3 4 5 6 7 8 9 '.split()

class TestFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self,None,-1,'grid sizer')
        panel=wx.Panel(self,-1)
        
        sizer=wx.GridBagSizer(hgap=5,vgap=5)
        for col in range(3):
            for row in range(3):
                button=wx.Button(panel,label=labels[row*3+col])
                sizer.Add(button,pos=(row,col))
        #跨行        
        bt=wx.Button(panel,label='sapn 3 rows')
        sizer.Add(bt,pos=(0,3),span=(3,1),flag=wx.EXPAND)
        #跨列
        bt=wx.Button(panel,label='span all columns')
        sizer.Add(bt,pos=(3,0),span=(1,4),flag=wx.EXPAND)
        #使最后的行和列可增长
        sizer.AddGrowableCol(3)
        sizer.AddGrowableRow(3)
        
        panel.SetSizer(sizer)
        sizer.Fit(self)
        
app=wx.App(False)
TestFrame().Show()
app.MainLoop()

 

posted @ 2015-01-26 21:28  mmjo  阅读(415)  评论(0编辑  收藏  举报