如何完整卸载wxpython_TextCtrl的WXPython C++部分被删除

我试图用Python为一个学校项目组装一个gui,但是我遇到了一个错误,我不明白为什么。在self.prompt.addAnswer(i, self.ansControls[i].GetValue()) File

"C:\Python27\lib\site-packages\wx-3.0-msw\wx_core.py", line 16712, in

getattr

raise PyDeadObjectError(self.attrStr % self._name) wx._core.PyDeadObjectError: The C++ part of the TextCtrl object has

been deleted, attribute access no longer allowed.

我理解错误的含义,textcrl对象不再存在,所以我无法访问它。我不明白为什么textcrl对象不再存在。流程如下:

框架将显示标签、文本框和按钮。用户输入数据并点击下一个。一切顺利。同样的PromptFrame实例也会被创建出来。但是这次,当用户点击next时,我得到了前面提到的错误。代码如下:

后台运行节目的服务:class AppService(object):

prompts = [Prompt_1, Prompt_2, Prompt_3, Prompt_4, Prompt_5, Prompt_6, Prompt_7,

Prompt_8, Prompt_9, Prompt_10, Prompt_11, Prompt_12, Prompt_13, Prompt_14,

Prompt_15, Prompt_16, Prompt_17, Prompt_18, Prompt_19]

skippedPromptIndices = []

def __init__(self):

print "Service Started"

PromptFrame(self, self.prompts[0], 0, len(self.prompts))

def doBack(self, curIndex, curPrompt):

if curIndex >= 0:

self.prompts[curIndex] = curPrompt

PromptFrame(self, self.prompts[curIndex - 1], curIndex - 1, len(self.prompts))

else:

posCurIndex = (curIndex * -1) - 1

self.prompts[posCurIndex] = curPrompt

backIndex = self.skippedPromptIndices.index(curIndex) - 1

nextPromptIndex = 0

if backIndex < 0:

nextPromptIndex = len(self.prompts) - 1

else:

nextPromptIndex = self.skippedPromptIndices[backIndex]

PromptFrame(self, self.prompts[(nextPromptIndex * -1) - 1], nextPromptIndex, len(self.prompts))

def doSkip(self, curIndex, curPrompt):

skipIndex = (curIndex + 1) * -1

if self.skippedPromptIndices.count(skipIndex) > 0:

self.skippedPromptIndices.remove(skipIndex)

self.skippedPromptIndices.append(skipIndex)

self.doNext(curIndex, curPrompt)

def doNext(self, curIndex, curPrompt):

if curIndex >= 0:

self.prompts[curIndex] = curPrompt

else:

self.prompts[(curIndex * -1) - 1] = curPrompt

if (curIndex >= 0 and curIndex < (len(self.prompts) - 1)):

PromptFrame(self, self.prompts[curIndex + 1], curIndex + 1, len(self.prompts))

elif len(self.skippedPromptIndices) > 0:

skipIndex = self.skippedPromptIndices.pop(0)

nextIndex = (skipIndex * -1) - 1

PromptFrame(self, self.prompts[nextIndex], skipIndex, len(self.prompts))

else:

dlg = wx.MessageDialog(self, "Done!", "Message", wx.OK)

dlg.ShowModal() # Shows it

dlg.Destroy() # finally destroy it when finished.

这是PromptFrame类:

^{pr2}$

谢谢你们的帮助!在

编辑:这是我的init.py文件:from MainFrame import MainFrame

import wx

app = wx.App(False)

frame = MainFrame(None, "My App")

app.MainLoop()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值