0
我不知道爲什麼下面的代碼不能正常工作,請大家幫我出:wxpython中的ScrolledPanel如何不以這種方式工作?
import wx
import wx.lib.scrolledpanel as scrolled
class TaskFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, parent = None, id = -1, title="ScrolledPanel", size = (500, 600))
MainPanel = wx.Panel(self)
NewPanel = scrolled.ScrolledPanel(parent = MainPanel, pos = (100, 100), size = (300, 200), id = -1, style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER, name="panel")
self.Button = wx.Button(parent = NewPanel, id = -1, label="Log", pos=(500, 30), size=(50, 20))
NewPanel.SetupScrolling()
class TaskApp(wx.App):
def OnInit(self):
self.frame = TaskFrame()
self.frame.Show()
self.SetTopWindow(self.frame)
return True
def main():
App = TaskApp(redirect = False)
App.MainLoop()
if __name__ == "__main__":
main()
日誌按鈕應該在NewPanel和NewPanel應該可以滾動,但它不是,有什麼問題?
其實,我相信你必須使用sizer。該文檔說:「假定ScrolledPanel將具有sizer,因爲它用於計算面板的最小虛擬大小等。」 – Mark 2011-01-05 17:29:47
非常感謝,夥計們! – Shane 2011-01-06 03:23:37