【问题标题】:wxPython possible Notebook GetPage bugwxPython 可能的 Notebook GetPage 错误
【发布时间】:2016-02-06 05:03:49
【问题描述】:

我已经编写了这个简单的代码来测试笔记本方法,我发现一些对我来说很奇怪的东西,但我不是 python/wxpython 专家,所以我决定问你我是否做错了什么,或者这是一个错误。 代码是:

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

当我在 Note 类上放置一个对象变量(如 self)时,当我调用 GetPage 方法时程序崩溃。这是笔记本制作这个东西的唯一方法,我真的不知道为什么。 我的python版本是3.4.3,wxPython Phoenix版本是3.0.3。

【问题讨论】:

  • 这在 wxPython Classic 3.0.2 和 2.8 中有效,所以它要么是 Phoenix 中的错误,要么是在调用 MainLoop 之前不应该工作的东西。

标签: python python-3.x wxpython wxwidgets


【解决方案1】:

我能够通过替换 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, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32 with Phoenix builds,包括最新 3.0.3.dev1826+ccc36fe msw(凤凰)

【讨论】:

  • 如果你能解释为什么 GetPage(0) 会崩溃
猜你喜欢
  • 2015-08-03
  • 1970-01-01
  • 2011-07-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-10-17
  • 1970-01-01
  • 2022-06-21
相关资源
最近更新 更多