# -*- coding: utf-8 -*- import time import wx interval = 1000 * 10 #10 second degrees = 0 blink_show = True def plus_1degree(): global tbi, app, degrees, blink_show if degrees < 360: degrees += 1 image = wx.EmptyImage(16, 16) bitmap = image.ConvertToBitmap() dc = wx.MemoryDC(bitmap) dc.SetBrush(wx.WHITE_BRUSH) dc.Clear() if degrees < 360 or blink_show: dc.SetBrush(wx.Brush(wx.RED)) dc.SetPen(wx.Pen(wx.RED)) dc.DrawEllipticArc(0, 0, 16, 16, 0, degrees) #a weird bug here if just use 'bitmap', hence the copying back and forth img2 = bitmap.ConvertToImage() bmp2 = img2.ConvertToBitmap() #bmp2.SetMask(wx.Mask(bmp2, wx.WHITE)) icon = wx.EmptyIcon() icon.CopyFromBitmap(bmp2) tbi.SetIcon(icon, str(degrees)) if degrees < 360: ca.Start(interval) else: ca.Start(500) blink_show = not blink_show def on_tbi_left_up(evt): global degrees, ca, interval degrees = 0 ca.Start(interval) def on_tbi_right_up(evt): global app app.Exit() app = wx.PySimpleApp() frame = wx.Frame(None, -1, "mmm") frame.Show(0) tbi = wx.TaskBarIcon() tbi.Bind(wx.EVT_TASKBAR_RIGHT_UP, on_tbi_right_up) tbi.Bind(wx.EVT_TASKBAR_LEFT_UP, on_tbi_left_up) ca = wx.CallLater(1000, plus_1degree) app.MainLoop()