本文整理匯總了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)
示例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)
示例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)
示例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
示例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
示例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)
示例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)