Thursday, March 31, 2011

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)?

From stackoverflow
  • 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)
    
    hinoglu : in fact there's no support for scrolling in PythonCard as mentioned by the maintainer. and that made me convert the code to pure wx from pythoncard, using scrolledpanels. thnaks for reply

0 comments:

Post a Comment