添加AuiToolbar导致“预期参数3类型int”

时间:2011-01-13 06:23:09

标签: wxpython

当我使用下面的代码并且我运行小应用程序时,框架甚至没有出现,并且显示“self._mgr.AddPane(tb4,aui.AuiPaneInfo ....”)的行给了我一个“期望的参数3类型int“错误。我正在使用Python 2.7和wxPython 2.8。这样做的正确方法是什么?

import wx
import wx.aui

# The lines below are copied/pasted from wxPython aui demo
try:
    from agw import aui
except ImportError:
    import wx.lib.agw.aui as aui
# End of copy/paste

class MyFrame(wx.Frame):
    def __init__(self, parent, id=-1, title='wx.aui Test', pos=wx.DefaultPosition, size=(800, 600), style=wx.DEFAULT_FRAME_STYLE):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)

        self._mgr = wx.aui.AuiManager(self)
        self.tree = wx.TreeCtrl(self, -1, wx.Point(0, 0), wx.Size(160, 250), wx.TR_DEFAULT_STYLE | wx.NO_BORDER)
        root = self.tree.AddRoot("AUI Project")

        # The lines below here were basically copied and pasted from wxPython demo
        tb4 = aui.AuiToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, agwStyle=aui.AUI_TB_DEFAULT_STYLE | aui.AUI_TB_OVERFLOW | aui.AUI_TB_TEXT | aui.AUI_TB_HORZ_TEXT)
        tb4.SetToolBitmapSize(wx.Size(16, 16))
        tb4_bmp1 = wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, wx.Size(16, 16))
        tb4.AddSimpleTool(-1, "Item 1", tb4_bmp1)
        tb4.AddSimpleTool(-1, "Item 2", tb4_bmp1)
        self._mgr.AddPane(tb4, aui.AuiPaneInfo().Name("tb4").Caption("Sample Bookmark Toolbar").ToolbarPane().Top())
        # End of copy and paste

        p = wx.Panel(self, -1)
        p.SetBackgroundColour(wx.GREEN)
        self._mgr.AddPane(self.tree, wx.LEFT, 'Window Navigator')
        self._mgr.AddPane(p, wx.CENTER, 'What')
        self._mgr.Update()


app = wx.App()
frame = MyFrame(None)
frame.Show()
app.MainLoop()

1 个答案:

答案 0 :(得分:2)