473,396 Members | 2,011 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.

"The C++ part of the .. Has been deleted, wsTaskBarIcon


I need some help. I cant seem to get rid of this error.

I can program a button that will exit the program and remove the icon in
the taskbar, but I have to tie it to OnTaskBarClose.

OnExit and OnCloseWindow do nothing and leave the icon in the taskbar, I
think I have tried every option, when you double click the icon it gives
you the error.

Traceback (most recent call last):
File "D:/Python24/simple.py", line 43, in OnTaskBarActivate
self.Show(true)
File "D:\Python24\Lib\site-packages\wx-2.5.4-msw-unicode\wx\_core.py",
line 11263, in __getattr__
raise PyDeadObjectError(self.attrStr % self._name)
wx._core.PyDeadObjectError: The C++ part of the MyFrame object has been
deleted, attribute access no longer allowed.

When the program runs, you can right click on the icon in the taskbar
and close and it works.
I hardcoded the file > Exit button to do the same thing and that works
too.
However if you click the top right X to just close the window, or on
close that's when the error happens.

How do I get the close to work properly from the default window? I have
been on this same thing for days. Any help would be greatly appreciated.

Heres the code, also attaching it.
from wxPython.wx import *
import sys
import os
ID_ABOUT = 101
ID_EXIT = 102

class MyFrame(wxFrame):
def __init__(self, NULL, ID, title):
wxFrame.__init__(self, NULL, ID, title,
wxDefaultPosition, wxSize(200, 150))
self.CreateStatusBar()
self.SetStatusText("This is the statusbar")

menu = wxMenu()
menu.Append(ID_ABOUT, "&About",
"More information about this program")
menu.AppendSeparator()
menu.Append(ID_EXIT, "E&xit", "Terminate the program")

menuBar = wxMenuBar()
menuBar.Append(menu, "&File");

self.SetMenuBar(menuBar)

EVT_MENU(self, ID_ABOUT, self.OnAbout)
EVT_MENU(self, ID_EXIT, self.OnTaskBarClose)
# make the TaskBar icon
self.tbIcon = wxTaskBarIcon()
# FIX ME WITH your Icon
icon = wxIcon('small.ico', wxBITMAP_TYPE_ICO)
self.tbIcon.SetIcon(icon, "It Doesnt work!")
EVT_TASKBAR_LEFT_DCLICK(self.tbIcon, self.OnTaskBarActivate)
EVT_TASKBAR_RIGHT_UP(self.tbIcon, self.OnTaskBarMenu)
EVT_MENU(self.tbIcon, self.TBMENU_CLOSE, self.OnTaskBarClose)
EVT_ICONIZE(self, self.OnIconify)

def OnIconify(self, evt):
self.Hide()

def OnTaskBarActivate(self, event):
self.Show(true)

TBMENU_CLOSE = 1001

def OnTaskBarMenu(self, event):
menu = wxMenu()
menu.Append(self.TBMENU_CLOSE, "Close")
self.tbIcon.PopupMenu(menu)
menu.Destroy()

def OnOK(self, event):
self.Show(false)

def OnExit(self, event):
del self.tbIcon
sys.exit()

def OnCloseWindow(self, event):
del self.tbIcon
sys.exit()

def OnTaskBarClose(self, event):
del self.tbIcon
sys.exit()

def OnAbout(self, event):
dlg = wxMessageDialog(self, "This sample program shows off\n"
"frames, menus, statusbars, and this\n"
"message dialog.",
"About Me", wxOK | wxICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
def TimeToQuit(self, event):
self.Destroy()

class MyApp(wxApp):
def OnInit(self):
frame = MyFrame(NULL, -1, "Hello from wxPython")
frame.Show(true)
self.SetTopWindow(frame)
return true
app = MyApp(0)
app.MainLoop()

Jul 18 '05 #1
0 1988

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

Similar topics

3
by: python newbie | 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: andrea_gavana | last post by:
Hello Alex, first of all, I would suggest you to upgrade wxPython to 2.5.5.1. There is no particular reason to stick with 2.4, whatever someone else is thinkink/saying. Secondly, I strongly...
2
by: Jeff Magouirk | last post by:
Dear All, I have written an update trigger that should write a message to an audit table When I try to update any field in the table I recieve the following error message - Stirng or...
2
by: Bill Short | last post by:
Hello All, I have a popup form that is called from a command button on the main form. The main form's data source is tblA. The data source for the popup form is a query that is based on tblA. ...
4
by: Earth Worm Jim | last post by:
I am using VS.Net 2003 on Windows 2003 Server (standard edition) and I am getting "The process cannot access the file because it is being used by another process" on DLL's in a VS.Net solution. ...
1
by: Amos | last post by:
In framework 1.0, In my Windows application in the breakpoints I add to one of the classes, I get this message: "The breakpoint will not currently be hit. No symbols have been loaded for this...
10
by: Ole | last post by:
Hi, Using VS2005 and a windows CE 5.0 device running CF2. Suddenly I can't debug my C# program from VS2005 - when setting a breakpoint I only see a ring instead of the normal red dot and when...
1
by: guy.flowers | last post by:
Hi Have a problem, Ill give some history to the problem and add a little example code to start with to see if anybody can help or if I am correct in what the problem is. I have been looking...
1
by: LiveCycle | last post by:
Hi, I've got a longstanding project that's been working fine for about a year. I was working on one of the pages, a simple download page. After making a little tweak on the page, I tried to...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.