Python win32gui.InsertMenuItem() Examples
The following are 9
code examples of win32gui.InsertMenuItem().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
win32gui
, or try the search function
.
Example #1
Source File: SysTrayIcon.py From LIFX-Control-Panel with MIT License | 6 votes |
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)
Example #2
Source File: systray.py From OpenBazaar-Installer with MIT License | 6 votes |
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)
Example #3
Source File: gui_win.py From ComicStreamer with Apache License 2.0 | 6 votes |
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)
Example #4
Source File: tray.py From MouseTracks with GNU General Public License v3.0 | 5 votes |
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)
Example #5
Source File: __init__.py From pyrexecd with MIT License | 5 votes |
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
Example #6
Source File: __init__.py From pyrexecd with MIT License | 5 votes |
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) return menu
Example #7
Source File: shell.py From eavatar-me with Apache License 2.0 | 5 votes |
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
Example #8
Source File: shell.py From eavatar-me with Apache License 2.0 | 5 votes |
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)
Example #9
Source File: shell.py From eavatar-me with Apache License 2.0 | 4 votes |
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)