wxPython Scroll Panel Spacing Issue

走远了吗. 提交于 2019-12-11 05:35:42

问题


I have tried to follow question and answer from this site regarding making a scrolly window with bitmaps, but I can't get it behave how I expected it to.

This is the panel code:

class ScrollyPanel(wxScrolledPanel.ScrolledPanel):
    def __init__(self, parent):
        wxScrolledPanel.ScrolledPanel.__init__(self, parent, style=wx.VSCROLL,
            size=(200,200))
        self.__sizer = wx.WrapSizer()
        self.SetupScrolling(scroll_x = False)
        self.addButton(200)
        self.SetSizer(self.__sizer)
        self.Bind(wx.EVT_SIZE, self.onSize)
        self.SetAutoLayout(True)
        self.Layout()

    def addButton(self, num):
        size = wx.Size(100, 100)
        for i in range(1, num):
            btn = wx.Button(self, wx.ID_ANY, "btn"+str(i), size = size)
            self.__sizer.Add(btn, 0, wx.ALL)

    def onSize(self, evt):
        size = self.GetSize()
        vsize = self.GetVirtualSize()
        self.SetVirtualSize((size[0], vsize[1]))
        evt.Skip()

I was expected closely aligned bitmaps of 100 x 100, but I am getting largely space bitmaps that aren't equally spaced.

Here is a screenshot of what I am seeing. I am totally confused as I cannot see any borders.

I am using wxPython 3 on Python 2.7.10

来源:https://stackoverflow.com/questions/47660325/wxpython-scroll-panel-spacing-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!