(self, icon_path=None)
Load the tray icon.

        Doesn't appear to be editable once it's been set.
        TODO: Look at http://www.brunningonline.net/simon/blog/archives/SysTrayIcon.py.html on how to edit it.
Load the tray icon.
Load the tray icon .
def _set_icon(self, icon_path=None):
        """Load the tray icon.

        Doesn't appear to be editable once it's been set.
        TODO: Look at http://www.brunningonline.net/simon/blog/archives/SysTrayIcon.py.html on how to edit it.
        """

        #Load icon as an image
        try:
            if icon_path is None or not os.path.isfile(icon_path):
                raise TypeError
            icon_flags = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE
            hinst = win32api.GetModuleHandle(None)
            hicon = win32gui.LoadImage(hinst, icon_path, win32con.IMAGE_ICON, 0, 0, icon_flags)
        
        #Fallback to default windows icon
        except TypeError:
            hicon = win32gui.LoadIcon(0, win32con.IDI_APPLICATION)
        
        flags = win32gui.NIF_ICON | win32gui.NIF_MESSAGE | win32gui.NIF_TIP
        nid = (self.hwnd, 0, flags, TRAY_EVENT, hicon, self.program_name)
        try:
            win32gui.Shell_NotifyIcon(win32gui.NIM_ADD, nid)
        except win32gui.error:
            # This is common when windows is starting, and this code is hit
            # before the taskbar has been created.
            # but keep running anyway - when explorer starts, we get the
            # TaskbarCreated message.
            pass

        self.logger.debug('Set tray icon.')
def _set_icon ( self , icon_path = None ) : #Load icon as an image try : if icon_path is None or not os . path . isfile ( icon_path ) : raise TypeError icon_flags = win32con . LR_LOADFROMFILE | win32con . LR_DEFAULTSIZE hinst = win32api . GetModuleHandle ( None ) hicon = win32gui . LoadImage ( hinst , icon_path , win32con . IMAGE_ICON , 0 , 0 , icon_flags ) #Fallback to default windows icon except TypeError : hicon = win32gui . LoadIcon ( 0 , win32con . IDI_APPLICATION ) flags = win32gui . NIF_ICON | win32gui . NIF_MESSAGE | win32gui . NIF_TIP nid = ( self . hwnd , 0 , flags , TRAY_EVENT , hicon , self . program_name ) try : win32gui . Shell_NotifyIcon ( win32gui . NIM_ADD , nid ) except win32gui . error : # This is common when windows is starting, and this code is hit # before the taskbar has been created. # but keep running anyway - when explorer starts, we get the # TaskbarCreated message. pass self . logger . debug ( 'Set tray icon.' )