[pywin32-bugs] [ pywin32-Bugs-3237838 ] cannot insert multi menu item into shell context menu
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2012-01-08 02:06:54
|
Bugs item #3237838, was opened at 2011-03-23 08:14 Message generated for change (Comment added) made by mhammond You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3237838&group_id=78018 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: pythonwin Group: None >Status: Closed >Resolution: Invalid Priority: 5 Private: No Submitted By: winterTTr (winterttr) Assigned to: Nobody/Anonymous (nobody) Summary: cannot insert multi menu item into shell context menu Initial Comment: I am trying to use pywin32 com to develop a shell extension which will add the menu item to shell context menu. I do a lot test using win32gui.InsertMenu, but i can not add more than one item to the context menu, I can just add one menu item, the following call to InsertMenu seem to be no effect. I tried use the context_menu.py under "C:\Python27\Lib\site-packages\win32comext\shell\demos\servers", and add one line like below: 39 items = [] 40 items.append("balabala...") But the result is that, only "balabala..." can be insert into the context menu, so the demo file also fail on my machine. I think this maybe a problem of pywin32, so I report it and hope you to check. Environment: windows 7 x86-32bit + python27 + pywin32-216.win32-py2.7.exe ---------------------------------------------------------------------- >Comment By: Mark Hammond (mhammond) Date: 2012-01-07 18:06 Message: For some reason, the fact the demo returns a constant string in GetCommandString() causes only the first item to be displayed. I've just checked in the patch below which makes it work as expected. Closing this as invalid as there isn't really a pywin32 bug here. --- a/com/win32comext/shell/demos/servers/context_menu.py +++ b/com/win32comext/shell/demos/servers/context_menu.py @@ -36,7 +36,7 @@ fname = shell.DragQueryFile(sm.data_handle, 0) msg = "&Hello from Python (with '%s' selected)" % fname idCmd = idCmdFirst - items = [] + items = ['First Python content menu item'] if (uFlags & 0x000F) == shellcon.CMF_NORMAL: # Check == here, since CMF_NORMAL=0 print "CMF_NORMAL..." items.append(msg) @@ -72,7 +72,11 @@ win32gui.MessageBox(hwnd, "Hello", "Wow", win32con.MB_OK) def GetCommandString(self, cmd, typ): - return "Hello from Python!!" + # If GetCommandString returns the same string for all items then + # the shell seems to ignore all but one. This is even true in + # Win7 etc where there is no status bar (and hence this string seems + # ignored) + return "Hello from Python (cmd=%d)!!" % (cmd,) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3237838&group_id=78018 |