当前位置: 首页>>代码示例>>Python>>正文


Python win32gui.InsertMenuItem方法代码示例

本文整理汇总了Python中win32gui.InsertMenuItem方法的典型用法代码示例。如果您正苦于以下问题:Python win32gui.InsertMenuItem方法的具体用法?Python win32gui.InsertMenuItem怎么用?Python win32gui.InsertMenuItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在win32gui的用法示例。


在下文中一共展示了win32gui.InsertMenuItem方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_menu

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import InsertMenuItem [as 别名]
def create_menu(self, menu, menu_options):
        for option_text, option_icon, option_action, option_id in menu_options[::-1]:
            if option_icon:
                option_icon = self.prep_menu_icon(option_icon)

            if option_id in self.menu_actions_by_id:
                item, extras = win32gui_struct.PackMENUITEMINFO(text=option_text,
                                                                hbmpItem=option_icon,
                                                                wID=option_id)
                win32gui.InsertMenuItem(menu, 0, 1, item)
            else:
                submenu = win32gui.CreatePopupMenu()
                self.create_menu(submenu, option_action)
                item, extras = win32gui_struct.PackMENUITEMINFO(text=option_text,
                                                                hbmpItem=option_icon,
                                                                hSubMenu=submenu)
                win32gui.InsertMenuItem(menu, 0, 1, item) 
开发者ID:samclane,项目名称:LIFX-Control-Panel,代码行数:19,代码来源:SysTrayIcon.py

示例2: create_menu

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import InsertMenuItem [as 别名]
def create_menu(self, menu, menu_options):
        for option_text, option_icon, option_action, option_id in menu_options[::-1]:
            if option_icon:
                option_icon = self.prep_menu_icon(option_icon)
            
            if option_id in self.menu_actions_by_id:                
                item, extras = win32gui_struct.PackMENUITEMINFO(text=option_text,
                                                                hbmpItem=option_icon,
                                                                wID=option_id)
                win32gui.InsertMenuItem(menu, 0, 1, item)
            else:
                submenu = win32gui.CreatePopupMenu()
                self.create_menu(submenu, option_action)
                item, extras = win32gui_struct.PackMENUITEMINFO(text=option_text,
                                                                hbmpItem=option_icon,
                                                                hSubMenu=submenu)
                win32gui.InsertMenuItem(menu, 0, 1, item) 
开发者ID:beville,项目名称:ComicStreamer,代码行数:19,代码来源:gui_win.py

示例3: _create_menu

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import InsertMenuItem [as 别名]
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) 
开发者ID:Peter92,项目名称:MouseTracks,代码行数:38,代码来源:tray.py

示例4: get_popup

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import InsertMenuItem [as 别名]
def get_popup(self):
        menu = win32gui.CreatePopupMenu()
        (item, _) = win32gui_struct.PackMENUITEMINFO(text='Quit', wID=self.IDI_QUIT)
        win32gui.InsertMenuItem(menu, 0, 1, item)
        win32gui.SetMenuDefaultItem(menu, 0, self.IDI_QUIT)
        (item, _) = win32gui_struct.PackMENUITEMINFO(text='Test', wID=123)
        win32gui.InsertMenuItem(menu, 0, 1, item)
        return menu 
开发者ID:euske,项目名称:pyrexecd,代码行数:10,代码来源:__init__.py

示例5: _create_status_menu

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import InsertMenuItem [as 别名]
def _create_status_menu(self):
        menu = win32gui.CreateMenu()
        for i, s in enumerate(base.status.STRINGS):
            fstate = 0
            if self.shell.user_status == i:
                fstate = win32con.MFS_CHECKED
            item, extras = win32gui_struct.PackMENUITEMINFO(
                text=base.status.STRINGS[i],
                hbmpItem=None,
                fState=fstate,
                wID=_ID_STATUS_AVAILABLE + i)
            win32gui.InsertMenuItem(menu, i, 1, item)

        self.status_menu = menu
        return self.status_menu 
开发者ID:eavatar,项目名称:eavatar-me,代码行数:17,代码来源:shell.py

示例6: addNewNotice

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import InsertMenuItem [as 别名]
def addNewNotice(self, notice, pop_last=False):
        self.notice_index = (self.notice_index + 1) % base.NUM_OF_NOTICES
        item, extras = win32gui_struct.PackMENUITEMINFO(
            text=notice.title,
            hbmpItem=None,
            wID=_ID_NOTICE + (self.notice_index % base.NUM_OF_NOTICES))

        win32gui.InsertMenuItem(self.notices_menu, 0, 1, item)
        if pop_last:
            win32gui.RemoveMenu(self.notices_menu, base.NUM_OF_NOTICES,
                                win32con.MF_BYPOSITION) 
开发者ID:eavatar,项目名称:eavatar-me,代码行数:13,代码来源:shell.py

示例7: create_menu

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import InsertMenuItem [as 别名]
def create_menu(self, menu):
        #        option_icon = self.prep_menu_icon(option_icon)
        item, extras = win32gui_struct.PackMENUITEMINFO(
            text=base.STR_EXIT,
            hbmpItem=None,
            wID=_ID_QUIT)

        win32gui.InsertMenuItem(menu, 0, 1, item)

        win32gui.InsertMenu(menu, 0, win32con.MF_BYPOSITION,
                            win32con.MF_SEPARATOR, None)

        win32gui.InsertMenu(menu, 0,
                            (win32con.MF_POPUP | win32con.MF_BYPOSITION),
                            self.notices_menu, base.STR_NOTICES_MENU)

        win32gui.InsertMenu(menu, 0, win32con.MF_BYPOSITION,
                            win32con.MF_SEPARATOR, None)

        win32gui.InsertMenu(menu, 0,
                            win32con.MF_POPUP | win32con.MF_BYPOSITION,
                            self.status_menu, base.STR_STATUS_MENU)

        win32gui.InsertMenu(menu, 0, win32con.MF_BYPOSITION,
                            win32con.MF_SEPARATOR, None)

        # item, extras = win32gui_struct.PackMENUITEMINFO(
        #     text=STR_OPEN_CONSOLE,
        #     hbmpItem=None,
        #     wID=_ID_OPEN_CONSOLE)
        # win32gui.InsertMenuItem(menu, 0, 1, item)

        item, extras = win32gui_struct.PackMENUITEMINFO(
            text=base.STR_OPEN_FOLDER,
            hbmpItem=None,
            wID=_ID_OPEN_FOLDER)

        win32gui.InsertMenuItem(menu, 0, 1, item)

        item, extras = win32gui_struct.PackMENUITEMINFO(
            text=base.STR_OPEN_WEBFRONT,
            hbmpItem=None,
            wID=_ID_OPEN_WEBFRONT)

        win32gui.InsertMenuItem(menu, 0, 1, item) 
开发者ID:eavatar,项目名称:eavatar-me,代码行数:47,代码来源:shell.py


注:本文中的win32gui.InsertMenuItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。