(self, menu, menu_options)
Generate the popup menu just before drawing.
        This is needed as it recursively runs on submenus.
Generate the popup menu just before drawing.
        This is needed as it recursively runs on submenus.
Generate the popup menu just before drawing . This is needed as it recursively runs on submenus .
def _create_menu(self, menu, menu_options):
        """Generate the popup menu just before drawing.
        This is needed as it recursively runs on submenus.
        """
        
        for menu_option in menu_options[::-1]:
            if menu_option.get('hidden', False):
                continue
        
            text = menu_option.get('name', 'Option')
            icon = menu_option.get('icon', None)
            action = menu_option.get('action', None)
            id = menu_option.get('_id')
            
            #Set icon
            if icon:
                try:
                    icon = self._set_icon_menu(icon)
                except pywintypes.error:
                    icon = None
            
            #Add menu item
            if id in self.menu_actions_by_id or action is None:                
                item, extras = win32gui_struct.PackMENUITEMINFO(text=text,
                                                                hbmpItem=icon,
                                                                wID=id)
                win32gui.InsertMenuItem(menu, 0, 1, item)
            
            #Add submenu
            else:
                submenu = win32gui.CreatePopupMenu()
                self._create_menu(submenu, action)
                item, extras = win32gui_struct.PackMENUITEMINFO(text=text,
                                                                hbmpItem=icon,
                                                                hSubMenu=submenu)
                win32gui.InsertMenuItem(menu, 0, 1, item)
def _create_menu ( self , menu , menu_options ) : for menu_option in menu_options [ : : - 1 ] : if menu_option . get ( 'hidden' , False ) : continue text = menu_option . get ( 'name' , 'Option' ) icon = menu_option . get ( 'icon' , None ) action = menu_option . get ( 'action' , None ) id = menu_option . get ( '_id' ) #Set icon if icon : try : icon = self . _set_icon_menu ( icon ) except pywintypes . error : icon = None #Add menu item if id in self . menu_actions_by_id or action is None : item , extras = win32gui_struct . PackMENUITEMINFO ( text = text , hbmpItem = icon , wID = id ) win32gui . InsertMenuItem ( menu , 0 , 1 , item ) #Add submenu else : submenu = win32gui . CreatePopupMenu ( ) self . _create_menu ( submenu , action ) item , extras = win32gui_struct . PackMENUITEMINFO ( text = text , hbmpItem = icon , hSubMenu = submenu ) win32gui . InsertMenuItem ( menu , 0 , 1 , item )