當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。