possible for a gridsizer to scroll?

I've been trying to get a scrolledwindow to work properly and have been having trouble. Now I'm
seeing some murmurs on Google about gridsizers being scrollable.... Is this the case?

If so, any tips?

I'm having trouble finding anything.

Or maybe someone could help me solve my problem with the ScrolledWindow widget? I'm at my
proverbial wit's end. This *almost* works, but the ScrolledWindow a) covers the toolbar, b)
doesn't go to the right margin, and c) doesn't refresh when scrolled.

Ideally I'd like a toolbar across the top of the page, and a bunch of thumbnails below it.

Thanks gigantically for any help, I'm probably 3 hours into this problem, and all of them late
night hours...

import wx

class MainWindow(wx.Frame):
    def __init__(self):

        wx.Frame.__init__(self, None, size=(700,400) )

        panel = wx.Panel(self)

        mainsizer = wx.BoxSizer(wx.VERTICAL)

···

#############################
        # toolbar
        #############################

        toolbar = wx.ToolBar(panel, -1, style=wx.TB_HORIZONTAL | wx.NO_BORDER)
        toolbar.SetBackgroundColour("BLACK")

        toolbar.SetToolBitmapSize((48,48))# this required for non-standard size buttons on MSW

        toolbar.AddSimpleTool(-1, wx.Image('open.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(),
'New', '')
        toolbar.AddSeparator()

        toolbar.AddSimpleTool(-1, wx.Image('open.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(),
'New', '')
        toolbar.AddSeparator()

        toolbar.Realize()

        mainsizer.Add(toolbar, 0, wx.ALL | wx.ALIGN_LEFT | wx.EXPAND, 0)

        mainsizer.Add((20,20), proportion=2)

        ################
        # scroll window
        ################

        sw = wx.ScrolledWindow(panel, size=(550,800)) #, style=wx.SUNKEN_BORDER)

        grid1 = wx.GridSizer(cols=5, hgap=5, vgap=5)

        for i in range(50):

            bmp = wx.Bitmap("0001.jpg", wx.BITMAP_TYPE_JPEG)
            pic = wx.BitmapButton(sw, -1, bmp, size=(200, 200) )
            grid1.Add(pic)

        #mainsizer.Add(grid1, 0, wx.CENTER)
        mainsizer.Add(grid1)

        panel.SetSizer(mainsizer)

        sw.EnableScrolling(1, 1)
        sw.SetScrollbars(20,10,10,700)

app = wx.App(redirect=0)
frm = MainWindow()
frm.Show()
app.MainLoop()

Hi Alec,

Alec Bennett wrote:

Or maybe someone could help me solve my problem with the ScrolledWindow widget? I'm at my
proverbial wit's end. This *almost* works, but the ScrolledWindow a) covers the toolbar, b)
doesn't go to the right margin, and c) doesn't refresh when scrolled.

Ideally I'd like a toolbar across the top of the page, and a bunch of thumbnails below it.
  

Don't put the toolbar into a panel, just use frame.CreateToolBar instead.

I don't think you need the panel as you have the scrolledwindow as a container within the frame.

I attached the changed code, it seems to work fine for me on WinVista.

Hope this helps
Werner

sizerproblem.py (1.47 KB)