[pywin32-checkins] pywin32/com/win32comext/shell/demos explorer_browser.py, 1.1, 1.2
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2008-07-26 07:02:26
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2322/com/win32comext/shell/demos Modified Files: explorer_browser.py Log Message: Support for INameSpaceTreeControl and new functions: SHCreateItemFromIDList, SHCreateItemFromParsingName, SHCreateItemFromRelativeName, SHCreateItemInKnownFolder, SHCreateItemWithParent and SHGetIDListFromObject and tests. Index: explorer_browser.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/demos/explorer_browser.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** explorer_browser.py 8 Jan 2008 00:41:44 -0000 1.1 --- explorer_browser.py 26 Jul 2008 07:02:34 -0000 1.2 *************** *** 3,6 **** --- 3,7 ---- # * CPU sits at 100% while running. + import sys import pythoncom from win32com.shell import shell, shellcon *************** *** 61,66 **** flags = (shellcon.FVM_LIST, shellcon.FWF_AUTOARRANGE | shellcon.FWF_NOWEBVIEW) eb.Initialize(self.hwnd, rect, (0, shellcon.FVM_DETAILS)) ! # And start browsing at the root of the namespace. ! eb.BrowseToIDList([], shellcon.SBSP_ABSOLUTE) #eb.FillFromObject(None, shellcon.EBF_NODROPTARGET); #eb.SetEmptyText("No known folders yet..."); --- 62,93 ---- flags = (shellcon.FVM_LIST, shellcon.FWF_AUTOARRANGE | shellcon.FWF_NOWEBVIEW) eb.Initialize(self.hwnd, rect, (0, shellcon.FVM_DETAILS)) ! if len(sys.argv)==2: ! # If an arg was specified, ask the desktop parse it. ! # You can pass anything explorer accepts as its '/e' argument - ! # eg, "::{guid}\::{guid}" etc. ! # "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" is "My Computer" ! pidl = shell.SHGetDesktopFolder().ParseDisplayName(0, None, sys.argv[1])[1] ! else: ! # And start browsing at the root of the namespace. ! pidl = [] ! eb.BrowseToIDList(pidl, shellcon.SBSP_ABSOLUTE) ! # and for some reason the "Folder" view in the navigator pane doesn't ! # magically synchronize itself - so let's do that ourself. ! # Get the tree control. ! sp = eb.QueryInterface(pythoncom.IID_IServiceProvider) ! try: ! tree = sp.QueryService(shell.IID_INameSpaceTreeControl, ! shell.IID_INameSpaceTreeControl) ! except pythoncom.com_error, exc: ! # this should really only fail if no "nav" frame exists... ! print "Strange - failed to get the tree control even though " \ ! "we asked for a EBO_SHOWFRAMES" ! print exc ! else: ! # get the IShellItem for the selection. ! si = shell.SHCreateItemFromIDList(pidl, shell.IID_IShellItem) ! # set it to selected. ! tree.SetItemState(si, shellcon.NSTCIS_SELECTED, shellcon.NSTCIS_SELECTED) ! #eb.FillFromObject(None, shellcon.EBF_NODROPTARGET); #eb.SetEmptyText("No known folders yet..."); |