473,396 Members | 1,833 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Please Hlp with msg: "The C++ part of the StaticText object has been deleted"

Hi,
I have a wxPython app which dump errors when I close it ( in
the debug output at bottom of Komodo, when I close my app. )

Where I got the code for my GUI:
Straight from the wxProject.py file which comes with the samples:
----
C:\Python23\Lib\site-packages\wx\samples\wxProject\wxProject.py ----

It basically consists of a splitterwindow, and I have a wxPanel
on the left side, which is set to a vertical box sizer. I used
the Add function of the sizer to simply add a wxStaticText control
at the very top.
The bottom half of this same left panel is a tree.
( u can ignore the *right* side of the splitter.. nothing exciting is
happening.. it's the same as in the wxProject.py sample ,
just a multilined edit contrl)

Anyway, when I click on a node of this tree, I change the text of the
static text control at top, to the text of the node. It actually works,
but when I close the app I get this:
----------------------------------------------
The stack trace:
E:\MyProjects1\python\backup
Traceback (most recent call last):
File "E:\MyProjects1\python\backup\wxProject.py", line 294, in
OnNodeChanged
self.testLab.SetLabel('test')
File "C:\Python23\Lib\site-packages\wx\_core.py", line 10617, in
__getattr__
raise PyDeadObjectError(self.attrStr % self._name)
wx._core.PyDeadObjectError: The C++ part of the StaticText object has been
deleted, attribute access no longer allowed.
---------------------------------------------
Here's how I add the wxStaticBox: ------------------------
# ok, first, the code below is actually in this __init__ function
class main_window(wxFrame):
def __init__(self, parent, id, title):
wxFrame.__init__(self, parent, -1, title, size = (650, 500),
style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_R ESIZE)

# first the left panel
# -------------------
self.MyLeftPanel = wxPanel(splitter,10004) #<--a random number I used
#
didn't want to use -1
self.MyLeftPanel.SetDimensions(0, 0, 100, 220)
self.leftSizer=wxBoxSizer(wxVERTICAL) # the sizer is born
self.MyLeftPanel.SetSizer(self.leftSizer)
self.MyLeftPanel.SetAutoLayout(true)

# then add the static text
# -------------------
self.aNewID=wxNewId()
self.testLabel = wxStaticText(self.MyLeftPanel,self.aNewID,'test label')
self.leftSizer.Add(self.testLabel)
Here's how I code the event handler: ------------------

def OnNodeChanged(self,event):
item = self.tree.GetSelection()
if (self.tree.ItemHasChildren(item) == 0):
#self.testLabel.SetLabel(self.tree.GetItemText(ite m))
self.testLabel.SetLabel('test')
# The commented-out line works too.. the static text does change
# to the static of the node --- very nice, if it weren't
# for the error when you close the app.

Any suggestions would be great.
-S

p.s.
Here's the kicker:
Try running C:\Python23\Lib\site-packages\wx\samples\wxProject\wxProject.py
yourself. (but first remove, say, the editor on the right side,
add a panel and a sizer,and then add a statictext control
and add a tree handler to set the label). And it will work
fine. No error dump when you close it!

I double and triple checked that I am doing the same thing as in the
original file. I don't want to dump my own py file, and start over
with the original sample file. i've written too much probably for that.

----------------------------
WX: wxPython WIN32-2.5.1.5
OS: Windows XP
PYTHON: From python.org, Version2.3

Jul 18 '05 #1
3 3582
Sorry about the two extra posts. Using Outlook Expr ( which told me it
didn't send it the first 2 times, though it did)
Jul 18 '05 #2
wxPyDeadObjectError is a catch that prevents you from getting a core
dump/memory-access-violation when you try to call a method or access an
attribute of an object which has already been cleaned up/destroyed by
the system. wxPyDeadObject's evaluate to false, so you can do this:
if self.testLab:
self.testLab.SetLabel('test')
or you can just catch the error:

try:
self.testLab.SetLabel( 'test' )
except wx.PyDeadObjectError, err:
pass # just ignore it...

In this case, it looks like the event is occurring after the testLab
widget has been destroyed. Since you likely don't want to change the
appearance of it at that point, nothing is lost.

HTH,
Mike

python newbie wrote:
....
File "E:\MyProjects1\python\backup\wxProject.py", line 294, in
OnNodeChanged
self.testLab.SetLabel('test')
File "C:\Python23\Lib\site-packages\wx\_core.py", line 10617, in
__getattr__
raise PyDeadObjectError(self.attrStr % self._name)
wx._core.PyDeadObjectError: The C++ part of the StaticText object has been
deleted, attribute access no longer allowed.

....
________________________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://www.vrplumber.com
http://blog.vrplumber.com

Jul 18 '05 #3
Sounds like a plan. Did a google group search originally, and I couldn't
find this info you just provided, so thanks a lot.

"Mike C. Fletcher" <mc******@rogers.com> wrote in message
news:ma**************************************@pyth on.org...
wxPyDeadObjectError is a catch that prevents you from getting a core
dump/memory-access-violation when you try to call a method or access an
attribute of an object which has already been cleaned up/destroyed by the
system. wxPyDeadObject's evaluate to false, so you can do this:
if self.testLab:
self.testLab.SetLabel('test')
or you can just catch the error:

try:
self.testLab.SetLabel( 'test' )
except wx.PyDeadObjectError, err:
pass # just ignore it...

In this case, it looks like the event is occurring after the testLab
widget has been destroyed. Since you likely don't want to change the
appearance of it at that point, nothing is lost.

HTH,
Mike

python newbie wrote:
...
File "E:\MyProjects1\python\backup\wxProject.py", line 294, in
OnNodeChanged
self.testLab.SetLabel('test')
File "C:\Python23\Lib\site-packages\wx\_core.py", line 10617, in
__getattr__
raise PyDeadObjectError(self.attrStr % self._name)
wx._core.PyDeadObjectError: The C++ part of the StaticText object has been
deleted, attribute access no longer allowed.

...
________________________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://www.vrplumber.com
http://blog.vrplumber.com

Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: StvB | last post by:
Hi, I have a wxPython app which dump errors when I close it ( in the debug output at bottom of Komodo, when I close my app. ) Where I got the code for my GUI: Straight from the wxProject.py...
0
by: Sugapablo | last post by:
I have two ASP pages. They basically query a database, and spit out the information as plain text in CSV format. The first has the SQL query hardcoded into it. The second takes a SQL query...
6
by: Aaron | last post by:
IIS 5.0 is throwing out "The requested resource is in use." for any site that uses ASP - HTML is executing fine. I have tried re-installing scripting, latest MDAC, and all my hotfixes are up to...
0
by: Pankaj Jain | last post by:
Hi All, I have a class A which is derived from ServicesComponent to participate in automatic transaction with falg Transaction.Required. Class A is exposed to client through remoting on Http...
5
by: Stan | last post by:
When I create a Web project and then try to add the files to it (Add Existing Item), I get this error message "The folder http://localhost/FinWeb is no longer availabe" In fact the folder and...
0
by: ashluvcadbury | last post by:
Hi all I have visual studio 2003 and also configured IIS.But not able to execute any web application. I am a beginner and all the small web applications I had made some days days ago were...
3
by: Kosmos | last post by:
Hey ya'll...I can't seem to figure out why I'm getting this error message, but it all started when I added the new line of code with the recSet5.AddNew --- when I ran the first line, the logic worked...
6
by: TC | last post by:
Hey All, I'm receiving a weird error in IE now: "The XML page cannot be displayed" This is even with the simplest of pages that I previously could view. Any ideas?
0
by: CoreyReynolds | last post by:
Hey all, I have a piece of code that dumps a bunch of data into a spreadsheet. Also rearranges it into a pivot table and then graphs the pivot table as well so my boss can get a clear view of the...
0
by: dougancil | last post by:
I have the following code: Public Class Payrollfinal Private Sub Payrollfinal_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.