How can I manage the size of grid elements

The grid control offers several different methods to manage the size of cells, rows, and columns. In this section we'll discuss each of these methods. Figure 14.4 displays some of the ways to change the size of a specific cell.

Listing 14.5 displays the code for creating a grid with resized cells, rows, and columns.

Figure 14.4 A sample grid, showing resized cells, rows, and columns

Listing 14.5 Code sample for resized cells import wx import wx.grid class TestFrame(wx.Frame):

wx.Frame._init_(self, None, title="Grid Sizes", size=(600,300)) grid = wx.grid.Grid(self) grid.CreateGrid(5,5) for row in range(5):

for col in range(5):

grid.SetCellValue(row, col, "(%s,%s)" % (row, col))

grid.SetCellSize(2, 2, 2, 3) grid.SetColSize(1, 125) grid.SetRowSize(1, 100)

app = wx.PySimpleApp() frame = TestFrame() frame.Show() app.MainLoop()

Figure 14.4 A sample grid, showing resized cells, rows, and columns

Was this article helpful?

0 0

Post a comment