[wxpython-users] wx.TaskBarIcon multiplying on explorer.exe crash

Mike Driscoll mdriscoll at co.marshall.ia.us
Thu May 1 07:21:58 PDT 2008


Robin Dunn wrote:
> <div class="moz-text-flowed" style="font-family: -moz-fixed">Mike 
> Driscoll wrote:
>
>>
>> So, here's the issue. From time to time, explorer.exe locks up and 
>> needs to be killed. Upon killing and restarting it from the Task 
>> Manager, my envelope icon will multiply itself for each unread email 
>> I have. 
>
>> <code>
>>
>> if self.unread_emails >= 1:                try:
>>         self.email_icon.RemoveIcon()
>>         self.email_timer.Stop()
>>     except: pass
>>     self.email_icon = mail_TBIcon.MailIcon(self.frame, 
>> self.unread_emails, self.temp_lst)
>>
>>     self.lastChecked = 0
>>     self.email_timer = wx.Timer(self)
>>     self.email_timer.Start(60000)
>>     self.Bind(wx.EVT_TIMER, self.emailChecker, self.email_timer)
>> else:
>>     try:
>>         self.email_timer.Stop()
>>         self.email_icon.RemoveIcon()                    except: pass
>>
>> </code>
>>
>> And yes, I know bare try/except statements are bad. Any ideas why 
>> this is happening though? I seem to only have this issue in my binary 
>> version (which I created with GUI2exe) and not if I run it straight 
>> from code.
>>
>
> You don't need to create a new icon each time, because RemoveIcon 
> doesn't destroy the object.  You should be able to just call SetIcon 
> on the old instance when you want to show it again.  If there is some 
> reason that you do need to create a new object, then you should call 
> Destroy on the old one instead of RemoveIcon.  (Destroy will call 
> RemoveIcon itself and then will delete the instance.)
>
>
>
Robin,

Thanks for the tip. For some reason I thought RemoveIcon did the 
destroying. I've re-ordered my code accordingly and I'll see if that 
fixes it. Thanks again!

Mike


More information about the wxpython-users mailing list