From: Robin Dunn [mailto:robin@alldunn.com]
Sent: Tuesday, June 19, 2007 1:01 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] ListCtrl + TBIcon issues
Mike Driscoll wrote:
> Hi,
>
> I am currently working on a little reminder program that
works kind of
> like Outlook's. I am using a ListCtrl in Report View and it works
> great most of the time. I have the ListCtrl and a few other
elements
> in a nested set of sizers. There's a top level BoxSizer and then 3
> others that go inside of it that hold the various elements.
>
> Most of the time, it loads fine. But every now and again,
it'll load
> and the widgets don't seem to go into their sizers. They all get
> scrunched up in the upper left corner of the screen
instead. I can't
> get it to do this consistently.
It probably just needs an extra call to Layout() somewhere.
I'll try this. I just wish it did it consistently so I could troubleshoot
it more easily.
> The other problem I am having is with the taskbar/system
tray icon. I
> am using a slightly modified version from the demo. Anyway, when I
> right-click it and tell it to close the program, it closes
but I get
> an error (see attached screenshot).
What are you using to close the program? You may want to
delay it using wx.CallAfter to make sure that there are no
more pending events for the window or the tbicon. Otherwise
the system can end up trying to send events to an object that
has already been destroyed. If all else fails make a small
runnable sample that shows the problem and send it here.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
Currently, the command in the TBIcon file is just like the demo's (I
think) in that it tells the frame object to close:
self.frame.Close()
I've tried that, but while it closes the frame, it doesn't get rid of the
TBIcon or stop the program itself from running and I get the following
traceback:
Traceback (most recent call last):
File
"\\someServer\\Scripts\PythonPackages\Development\zimbra\reminder.py",
line 328, in updateAlerts
self.list_ctrl.DeleteAllItems()
File "C:\Python24\lib\site-packages\wx-2.8-msw-ansi\wx\_core.py", line
13750, in __getattr__
raise PyDeadObjectError(self.attrStr % self._name)
wx._core.PyDeadObjectError: The C++ part of the TestListCtrl object has
been deleted, attribute access no longer allowed.
I've tried catching the close event like this:
self.frame.Bind(wx.EVT_CLOSE, self.onClose)
def onClose(self, event):
'''
Closes the program and deletes the icon from the system tray.
'''
print 'in onClose'
try:
self.tbicon.Destroy()
wx.GetApp().ProcessIdle()
except:
pass
self.frame.Destroy()
This works if I close with the little "x" in the upper right hand corner
of my app. I tried sticking a wx.CallAfter() at the top and bottom of the
try as well as before and after the self.frame.Destroy(). I also tried
self.frame.Close() in all those circumstances. Interestingly, if
wx.CallAfter() is the beginning line in the try statement and I use
self.frame.Close(), it goes into an infinite loop.
Any other ideas?
Thanks,
Mike
···
-----Original Message-----