File: GridBagSizer.1.py

package info (click to toggle)
wxpython4.0 4.2.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 221,752 kB
  • sloc: cpp: 962,555; python: 230,573; ansic: 170,731; makefile: 51,756; sh: 9,342; perl: 1,564; javascript: 584; php: 326; xml: 200
file content (46 lines) | stat: -rw-r--r-- 1,166 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
##Chris Barker
#!/usr/bin/env python

"""
A simple test of the GridBagSizer

http://wiki.wxpython.org/index.cgi/WriteItYourself

"""

import wx

class MyFrame(wx.Frame):
    def __init__(self, parent, ID, title):
        wx.Frame.__init__(self, parent, ID, title, wx.DefaultPosition)

        Buttons = []
        for i in range(6):
            Buttons.append(wx.Button(self,-1, "Button %i"%(i)))

        sizer = wx.GridBagSizer(9, 9)
        sizer.Add(Buttons[0], (0, 0), wx.DefaultSpan,  wx.ALL, 5)
        sizer.Add(Buttons[1], (1, 1), (1,7), wx.EXPAND)
        sizer.Add(Buttons[2], (6, 6), (3,3), wx.EXPAND)
        sizer.Add(Buttons[3], (3, 0), (1,1), wx.ALIGN_CENTER)
        sizer.Add(Buttons[4], (4, 0), (1,1), wx.ALIGN_LEFT)
        sizer.Add(Buttons[5], (5, 0), (1,1), wx.ALIGN_RIGHT)

        sizer.AddGrowableRow(6)
        sizer.AddGrowableCol(6)

        self.SetSizerAndFit(sizer)
        self.Centre()


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

if __name__ == "__main__":
    app = MyApp(0)
    app.MainLoop()