[pywin32-checkins] /hgrepo/p/py/pywin32/pywin32: 2 new changesets
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <pyw...@li...> - 2012-01-19 02:56:09
|
changeset bd57d6c69bb0 in /hgrepo/p/py/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgrepo/p/py/pywin32/pywin32?cmd=changeset;node=bd57d6c69bb0 summary: show how a shell context menu extension can show multiple items changeset 8fc48a195771 in /hgrepo/p/py/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgrepo/p/py/pywin32/pywin32?cmd=changeset;node=8fc48a195771 summary: fix occasional exception in pythonwin's ImportFile (bug 3438431) diffstat: Pythonwin/pywin/framework/scriptutils.py | 6 +++++- com/win32comext/shell/demos/servers/context_menu.py | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diffs (41 lines): diff -r 57fc41295aa0 -r 8fc48a195771 Pythonwin/pywin/framework/scriptutils.py --- a/Pythonwin/pywin/framework/scriptutils.py Mon Jan 02 18:43:11 2012 +1100 +++ b/Pythonwin/pywin/framework/scriptutils.py Thu Jan 19 13:55:10 2012 +1100 @@ -393,7 +393,11 @@ path, modName = os.path.split(pathName) modName, modExt = os.path.splitext(modName) newPath = None - for key, mod in sys.modules.iteritems(): + # note that some packages (*cough* email *cough*) use "lazy importers" + # meaning sys.modules can change as a side-effect of looking at + # module.__file__ - so we must take a copy (ie, items() in py2k, + # list(items()) in py3k) + for key, mod in sys.modules.items(): if hasattr(mod, '__file__'): fname = mod.__file__ base, ext = os.path.splitext(fname) diff -r 57fc41295aa0 -r 8fc48a195771 com/win32comext/shell/demos/servers/context_menu.py --- a/com/win32comext/shell/demos/servers/context_menu.py Mon Jan 02 18:43:11 2012 +1100 +++ b/com/win32comext/shell/demos/servers/context_menu.py Thu Jan 19 13:55:10 2012 +1100 @@ -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,) def DllRegisterServer(): import _winreg |