2015-11-05 33 views
0

我已經爲測試筆記本方法做了這個簡單的代碼,我發現了一些非常奇怪的東西,但我不是一個Python/wxpython專家,我決定問你我是否犯了錯誤,或者如果這是一個錯誤。 的代碼是:wxPython可能筆記本GetPage缺陷

import wx 
class Note(wx.Notebook): 
    def __init__(self, parent): 
     wx.Notebook.__init__(self, parent) 
     self.dummy = 0#or self.panel = wx.Panel(self) or evry other thing with the self. 
     wx.Notebook.AddPage(self, wx.Panel(self), 'page') 
app = wx.App() 
f = wx.Frame(None) 
n = Note(f) 
#the code works up to here 
n.GetPage(0)#with this line the progra crash 

當我在注類對象變量放置時,我調用GETPAGE方法程序崩潰(如自)。這是做這件事的筆記本唯一的方法,我真的不知道爲什麼。 我的Python版本是3.4.3,而wxPython Phoenix版本是3.0.3。

+0

這在wxPython經典3.0.2和2.8的工程,所以它可能是一個錯誤在鳳凰或一些不應該工作直到「MainLoop」被調用。 –

回答

0

我能夠通過替換選擇給定頁面的GetPage(0)代碼,然後重試它來解決問題。

#n.GetPage(0)#with this line the progra crash 
n.ChangeSelection(0) 
aPage = n.GetCurrentPage() 
print(aPage) 

這得到這一輪我在Microsoft Windows 7體驗的Python 3.4.3崩潰(v3.4.3:9b73f1c3e601,2015年2月24日,22時44分40秒)[MSC v.1600 64位( AMD64)]與鳳凰建立,包括最新的 3.0.3.dev1826 + ccc36fe msw(鳳凰)

+0

如果你能解釋爲什麼它會崩潰與GetPage(0) – AlokThakur