2011-01-13 37 views
1

當我使用下面的代碼並運行小應用程序時,該框架甚至沒有顯示,並且顯示「self._mgr.AddPane(tb4,aui .AuiPaneInfo ......」給我一個‘期望的參數3 int類型’的錯誤。我使用Python 2.7和2.8 wxPython的是什麼這樣做的正確方法?添加AuiToolbar會導致「期望的參數3類型int」

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

回答

相關問題