]> git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-14/grid_attr.py
Added the sample code from wxPython In Action to the samples dir
[wxWidgets.git] / wxPython / samples / wxPIA_book / Chapter-14 / grid_attr.py
1 import wx
2 import wx.grid
3
4 class TestFrame(wx.Frame):
5
6
7 def __init__(self):
8 wx.Frame.__init__(self, None, title="Grid Attributes",
9 size=(600,300))
10 grid = wx.grid.Grid(self)
11 grid.CreateGrid(10,6)
12 for row in range(10):
13 for col in range(6):
14 grid.SetCellValue(row, col, "(%s,%s)" % (row, col))
15
16 grid.SetCellTextColour(1, 1, "red")
17 grid.SetCellFont(1,1, wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD))
18 grid.SetCellBackgroundColour(2, 2, "light blue")
19
20 attr = wx.grid.GridCellAttr()
21 attr.SetTextColour("navyblue")
22 attr.SetBackgroundColour("pink")
23 attr.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD))
24
25 grid.SetAttr(4, 0, attr)
26 grid.SetAttr(5, 1, attr)
27 grid.SetRowAttr(8, attr)
28
29
30 app = wx.PySimpleApp()
31 frame = TestFrame()
32 frame.Show()
33 app.MainLoop()