I am trying to create a new item in the Windows System Menu for my app and have an action performed when it is click.
I have wor开发者_运维技巧ked out the frist part using the below code.
import win32con
import win32gui
hwnd = win32gui.GetForegroundWindow ()
hmenu = win32gui.GetSystemMenu (hwnd, False)
win32gui.AppendMenu(hmenu, win32con.MF_SEPARATOR, 0, '')
win32gui.AppendMenu(hmenu, win32con.MF_STRING, 100, 'New Menu Item')
I can not work out how link a function to the button? So that an action is performed when it is click
Any help would be great.
Thanks.
Donald.
p.s. Using Python 2.6.5 and Windows XP
You have to hook into the windows procedure of the menu and handle the messages being sent. See e.g. http://wiki.wxpython.org/HookingTheWndProc
精彩评论