wxNotebook and wxGrid compatibility

Off the top of my head, I always stick a wx.Panel onto a notebook page.

Hence if you stick your grid (or any control) onto a sizer which is on a
panel, then that panel onto the notebook page it should work.

I' m not the worlds best programmer, so this advice may be wrong!!!!!, but
works for me.

Regards

Richard

···

On Tuesday 24 April 2007 13:09, Daniel Sisco wrote:

Hey guys,

I'm trying to create a wxNotebook object containing two things: a wxPanel
instance with some buttons, etc.., and a wxGrid containing some data. I've
got the Panel instance working just fine - but for some reason the wxGrid
is resisting me. This is what I'm doing:

class MainFrame(wx.Frame):

    def __init__(self, parent, id, title, pos=wx.DefaultPosition,
             size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE):

        panel = wx.Panel(self)
        notebook = wx.Notebook(panel)

        # this page works fine
        page1 = EntryPage(notebook)
        notebook.AddPage(page1, "page 1")

        page2 = GraphicsPage(notebook)
        notebook.AddPage(page2, "page 2")

        sizer = wx.BoxSizer()
        sizer.Add(notebook, 1, wx.EXPAND)
        panel.SetSizer(sizer)

class GraphicsPage(wx.grid.Grid):

    def __init__(self, parent):

        wx.grid.Grid.__init__(self, parent, -1, size = parent.GetSize())
        table = CustomDataTable()

class CustomDataTable(wx.grid.PyGridTableBase):

    def __init__(self):

        wx.grid.PyGridTableBase.__init__(self)
        self.colLabels = ['ID', 'Description']
        self.dataTypes = [wx.grid.GRID_VALUE_NUMBER,
                                  wx.grid.GRID_VALUE_STRING]
        self.data = [ [1, "one"],
                          [2, "two"],
                          [3, "three"]]

The final result is that the first notebook page shows up fine - but the
grid page only shows a gray block for the upper header - no data or header
text. I think this might have something to do with my use of wxBoxSizer?

Any help is appreciated.