wx.grid scrollbars issue

Hi All,

I am having a problem with a wx.grid not having
scrollbars appear. Have read several threads on this
unfortunately none that seem to solve my problem. For some reason the
scrollbars will not appear when I place the grid inside a sizer (which
I need to do). If you
comment out self.doLayout() the scrollbars will appear, unfortunately this is no help to me because as mentioned I need that grid in a sizer.

I have attached a simplified section of my code showing the problem.

Any input on this problem greatly appreciated.

···

import wx
import wx.grid

class Frame(wx.Frame):
“”“Main Frame for App.”""
def init(self, parent=None, id=
wx.ID_ANY, title=“Default”, pos=wx.DefaultPosition,
size=(800,600), style=wx.DEFAULT):
wx.Frame.init(self, parent, id, title, pos, size, style, name=‘frame’)

    self.SetMinSize(size)         
    self.makeGrid()
    self.doLayout()

def makeGrid(self):
    self.grid = wx.grid.Grid(self)
    self.grid.CreateGrid(50,50)
    for row in range(20):
        for col in range(6):
            self.grid.SetCellValue(row, col,

“cell (%d,%d)” % (row, col))
def doLayout(self):
self.sizer1 = wx.BoxSizer
(wx.VERTICAL)
for widget in [self.grid]:
self.sizer1.Add(widget)

    self.SetSizer(self.sizer1)

regards,
aaron.

aaron barclay wrote:

Hi All,

I am having a problem with a wx.grid not having scrollbars appear. Have read several threads on this unfortunately none that seem to solve my problem. For some reason the scrollbars will not appear when I place the grid inside a sizer (which I need to do). If you
comment out self.doLayout() the scrollbars will appear, unfortunately this is no help to me because as mentioned I need that grid in a sizer.

I have attached a simplified section of my code showing the problem.

Any input on this problem greatly appreciated.

I'm not sure yet what's going wrong, but changing your Add statement to this does fix it:

             self.sizer1.Add(widget, 1, wx.EXPAND)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!