Search code examples
pythonwxpythonscrollpythoncard

adding scrollbars to pythoncard application


scrollingwindow as main frame for the application is not supported yet for pythoncard. how can i add scrollbars to main frame(background)?


Solution

  • Ive never used pythoncard but in pure wxpython you can just put a ScrolledWindow inside the frame, then use a sizer to controll the scrollbars (asumming the contents of the sizer dont fit in the window). Eg this short code snipit will give you a window with a vertical scrollbar.

    class Scrolled(wx.ScrolledWindow):
        def __init__(self, parent):
            wx.ScrolledWindow.__init__(self, parent, size=(200,200))
            self.SetScrollRate(0, 10);
            sizerV = wx.BoxSizer(wx.VERTICAL)
            #create a bunch of stuff in the sizer which doesnt fit
            for i in range(0,50):
                text = "Line: " + str(i)
                sizerV.Add(wx.StaticText(self, label=text), 0)
    
            self.SetSizer(sizerV)
    
    class Frame(wx.Frame):
        def __init__(self, parent):
            wx.Frame.__init__(self, parent, size=(200,200), Scrolled(self)
                title="Scroll Bars", style=wx.CAPTION)