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\sam ples\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.Se tLabel('test')
File "C:\Python23\Li b\site-packages\wx\_co re.py", line 10617, in
__getattr__
raise PyDeadObjectErr or(self.attrStr % self._name)
wx._core.PyDead ObjectError: 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(wxF rame):
def __init__(self, parent, id, title):
wxFrame.__init_ _(self, parent, -1, title, size = (650, 500),
style=wxDEFAULT _FRAME_STYLE|wx NO_FULL_REPAINT _ON_RESIZE)
# first the left panel
# -------------------
self.MyLeftPane l = wxPanel(splitte r,10004) #<--a random number I used
#
didn't want to use -1
self.MyLeftPane l.SetDimensions (0, 0, 100, 220)
self.leftSizer= wxBoxSizer(wxVE RTICAL) # the sizer is born
self.MyLeftPane l.SetSizer(self .leftSizer)
self.MyLeftPane l.SetAutoLayout (true)
# then add the static text
# -------------------
self.aNewID=wxN ewId()
self.testLabel = wxStaticText(se lf.MyLeftPanel, self.aNewID,'te st label')
self.leftSizer. Add(self.testLa bel)
Here's how I code the event handler: ------------------
def OnNodeChanged(s elf,event):
item = self.tree.GetSe lection()
if (self.tree.Item HasChildren(ite m) == 0):
#self.testLabel .SetLabel(self. tree.GetItemTex t(item))
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\sam ples\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 3 3631
Sorry about the two extra posts. Using Outlook Expr ( which told me it
didn't send it the first 2 times, though it did)
wxPyDeadObjectE rror 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.Se tLabel('test')
or you can just catch the error:
try:
self.testLab.Se tLabel( 'test' )
except wx.PyDeadObject Error, 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 OnNodeChange d self.testLab.Se tLabel('test') File "C:\Python23\Li b\site-packages\wx\_co re.py", line 10617, in __getattr__ raise PyDeadObjectErr or(self.attrStr % self._name) wx._core.PyDea dObjectError: 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
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******@roger s.com> wrote in message
news:ma******** *************** *************** @python.org... wxPyDeadObjectE rror 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.Se tLabel('test') or you can just catch the error:
try: self.testLab.Se tLabel( 'test' ) except wx.PyDeadObject Error, 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 OnNodeChang ed self.testLab.Se tLabel('test') File "C:\Python23\Li b\site-packages\wx\_co re.py", line 10617, in __getattr__ raise PyDeadObjectErr or(self.attrStr % self._name) wx._core.PyDe adObjectError: 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 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
|
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 from a webform.
Now, the hardcoded results, I can click "Save Page As" when the results
come up and save it as a text file.
The other, while it seems to be the same results exactly, gives me an
|
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 date. I have also
tried re-syncing the IWAM account but that didn't work either... Running
the webs in HIGH (isolated) did not help either. I disabled ISAPI
caching, and re-enabled it .. nothing ... rebooted the server, restarted
IIS several times ...
|
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 channal hosting into IIS.
There is a class B which is also available through remoting hosted on IIS on the same URI. B creates new of A inside a function. It succeed and able to create instance of A inside B first time. But it failes in 2nd attempt when...
|
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 the virtual directory FinWeb both exist and project
compiles just fine, but I cannot add the existing files to it.
If I create a project with a different name (FinWeb2) it works fine.
| |
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 working perfectly .But now when i tried to execute
them again ,they are giving the error"Http error-404 object not
found" .what should I do.Please help me out.
thanks and regards
|
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 and the fields were populated properly, when I added all the rest, it wouldn't run and even when I tried to go back, it still won't run now...I am getting the following error message:
"Either BOF or EOF is True, or the current record has been...
|
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?
|
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 data.
This question is two part. One, I seem to be getting the title error at the starting line stating:
oSheet.Range(rng).Select
With Selection
shp.Left = .Left
shp.Top = .Top
|
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
exportfileButton.Enabled = False
Dim oCmd As System.Data.SqlClient.SqlCommand
Dim oDr As System.Data.SqlClient.SqlDataReader
oCmd = New System.Data.SqlClient.SqlCommand
Dim _CMD As SqlCommand = New SqlCommand
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |