我在Windows 8操作系统上使用wxPython v3.0和python v2.7。 代码如下所示。
问题:如果您将垂直滚动条完全滚动到底部并将水平滚动条完全滚动到右侧,那么您应注意到面板底部和面板右侧如下图所示。怎么避免这个?这是默认行为还是我做错了什么?如果有人可以在他/她的系统上测试这个并确认这是否是正常行为会很棒吗?
代码:
import wx
import wx.lib.scrolledpanel
class GUI(wx.Frame):
def __init__(self, parent, id, title):
screenWidth = 700
screenHeight = 400
screenSize = (screenWidth, screenHeight)
wx.Frame.__init__(self, None, id, title, size=screenSize)
myFont = wx.Font(15, wx.MODERN, wx.NORMAL, wx.BOLD)
mainSizer = wx.BoxSizer(wx.VERTICAL)
panelsSizer = wx.BoxSizer(wx.HORIZONTAL)
sizer1 = wx.BoxSizer(wx.VERTICAL)
sizer2 = wx.BoxSizer(wx.VERTICAL)
mainPanel = wx.lib.scrolledpanel.ScrolledPanel(self, -1,style=wx.SIMPLE_BORDER)
mainPanel.SetupScrolling()
panel1 = wx.lib.scrolledpanel.ScrolledPanel(mainPanel, -1, style=wx.SIMPLE_BORDER)
panel1.SetupScrolling(scroll_y=False)
panel2 = wx.lib.scrolledpanel.ScrolledPanel(mainPanel, -1, style=wx.SIMPLE_BORDER)
panel1.SetBackgroundColour('#cccFFF')
panel2.SetBackgroundColour('#FFFaaa')
panelsSizer.Add(panel1, 1, wx.ALL|wx.EXPAND)
panelsSizer.Add(panel2, 2, wx.ALL|wx.EXPAND)
mainPanel.SetSizer(panelsSizer)
k = 0
#Populating the panel-1 with panels to show scroll bars
for i in range(1,20):
lPanels = 'lPanel'+str(k)
lPanels = wx.Panel(panel1)
label0 = str(k+1)+ '. '+'Panel-1 #############################'
text0 = wx.StaticText(lPanels, -1, label0)
text0.SetFont(myFont)
sizer1.Add(lPanels, 0, wx.ALL|wx.EXPAND, 5)
sizer1.Add(wx.StaticLine(panel1), 0, wx.ALL|wx.EXPAND, 0)
k += 1
k = 0
#Populating the panel-2 with panels to show the scroll bars
for i in range(1,20):
sPanel ='sPanel' +str(k)
sPanel = wx.Panel(panel2)
label = str(k)+ '. Panel-2#############################'
text = wx.StaticText(sPanel, -1, label)
text.SetFont(myFont)
sizer2.Add(sPanel, 0, wx.ALL|wx.EXPAND, 5)
sizer2.Add(wx.StaticLine(panel2), 0, wx.ALL|wx.EXPAND, 0)
k += 1
panel1.SetSizer(sizer1)
panel2.SetSizer(sizer2)
mainSizer.Add(mainPanel, 15, wx.EXPAND|wx.ALL)
self.SetSizer(mainSizer)
if __name__=='__main__':
app = wx.App()
frame = GUI(parent=None, id=-1, title="Test")
frame.Show()
app.MainLoop()
感谢您的时间!
答案 0 :(得分:1)
这很正常。 wx.ScrolledWindow将虚拟大小四舍五入到滚动速率的下一个倍数,因此最终得到0和滚动速率额外像素。