本文整理汇总了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)