python类SHGetPathFromIDList()的实例源码

directories.py 文件源码 项目:libdesktop 作者: bharadwaj-raju 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __windows_get_dir(win_dir):

    from win32com.shell import shell

    df = shell.SHGetDesktopFolder()
    pidl = df.ParseDisplayName(0, None,
                               '::%s' % __WINDOWS_FOLDER_GUIDS[win_dir])[1]

    return shell.SHGetPathFromIDList(pidl)
browse_for_folder.py 文件源码 项目:Email_My_PC 作者: Jackeriss 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def BrowseCallbackProc(hwnd, msg, lp, data):
    if msg== shellcon.BFFM_INITIALIZED:
        win32gui.SendMessage(hwnd, shellcon.BFFM_SETSELECTION, 1, data)
    elif msg == shellcon.BFFM_SELCHANGED:
        # Set the status text of the
        # For this message, 'lp' is the address of the PIDL.
        pidl = shell.AddressAsPIDL(lp)
        try:
            path = shell.SHGetPathFromIDList(pidl)
            win32gui.SendMessage(hwnd, shellcon.BFFM_SETSTATUSTEXT, 0, path)
        except shell.error:
            # No path for this PIDL
            pass
shellexecuteex.py 文件源码 项目:Email_My_PC 作者: Jackeriss 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def ExplorePIDL():
    pidl = shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_DESKTOP)
    print "The desktop is at", shell.SHGetPathFromIDList(pidl)
    shell.ShellExecuteEx(fMask=shellcon.SEE_MASK_NOCLOSEPROCESS,
                         nShow=win32con.SW_NORMAL,
                         lpClass="folder", 
                         lpVerb="explore", 
                         lpIDList=pidl)
    print "Done!"
dialogs_legacy.py 文件源码 项目:inter 作者: rsms 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def GetFolder(message=None):
    """
    Select folder dialog. Returns path if one is selected. Otherwise it returns None.
    Availability: FontLab, Macintosh, PC
    """
    path = None
    if MAC:
        if haveMacfs:
            fss, ok = macfs.GetDirectory(message)
            if ok:
                path = fss.as_pathname()
        else:
            from robofab.interface.mac.getFileOrFolder import GetFileOrFolder
            # This _also_ allows the user to select _files_, but given the
            # package/folder dichotomy, I think we have no other choice.
            path = GetFileOrFolder(message)
    elif PC:
        if inFontLab:
            if not message:
                message = ''
            path = fl.GetPathName('', message)
        else:
            myTuple = shell.SHBrowseForFolder(0, None, message, 64)
            try:
                path = shell.SHGetPathFromIDList(myTuple[0])
            except:
                pass
    else:
        _raisePlatformError('GetFile')
    return path
browse_for_folder.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def BrowseCallbackProc(hwnd, msg, lp, data):
    if msg== shellcon.BFFM_INITIALIZED:
        win32gui.SendMessage(hwnd, shellcon.BFFM_SETSELECTION, 1, data)
    elif msg == shellcon.BFFM_SELCHANGED:
        # Set the status text of the
        # For this message, 'lp' is the address of the PIDL.
        pidl = shell.AddressAsPIDL(lp)
        try:
            path = shell.SHGetPathFromIDList(pidl)
            win32gui.SendMessage(hwnd, shellcon.BFFM_SETSTATUSTEXT, 0, path)
        except shell.error:
            # No path for this PIDL
            pass
shellexecuteex.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def ExplorePIDL():
    pidl = shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_DESKTOP)
    print "The desktop is at", shell.SHGetPathFromIDList(pidl)
    shell.ShellExecuteEx(fMask=shellcon.SEE_MASK_NOCLOSEPROCESS,
                         nShow=win32con.SW_NORMAL,
                         lpClass="folder", 
                         lpVerb="explore", 
                         lpIDList=pidl)
    print "Done!"
browse_for_folder.py 文件源码 项目:CodeReader 作者: jasonrbr 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def BrowseCallbackProc(hwnd, msg, lp, data):
    if msg== shellcon.BFFM_INITIALIZED:
        win32gui.SendMessage(hwnd, shellcon.BFFM_SETSELECTION, 1, data)
    elif msg == shellcon.BFFM_SELCHANGED:
        # Set the status text of the
        # For this message, 'lp' is the address of the PIDL.
        pidl = shell.AddressAsPIDL(lp)
        try:
            path = shell.SHGetPathFromIDList(pidl)
            win32gui.SendMessage(hwnd, shellcon.BFFM_SETSTATUSTEXT, 0, path)
        except shell.error:
            # No path for this PIDL
            pass
shellexecuteex.py 文件源码 项目:CodeReader 作者: jasonrbr 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def ExplorePIDL():
    pidl = shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_DESKTOP)
    print("The desktop is at", shell.SHGetPathFromIDList(pidl))
    shell.ShellExecuteEx(fMask=shellcon.SEE_MASK_NOCLOSEPROCESS,
                         nShow=win32con.SW_NORMAL,
                         lpClass="folder", 
                         lpVerb="explore", 
                         lpIDList=pidl)
    print("Done!")
platform.py 文件源码 项目:chirp_fork 作者: mach327 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def gui_select_dir(self, start_dir=None):
        from win32com.shell import shell

        try:
            pidl, _, _ = shell.SHBrowseForFolder()
            fname = shell.SHGetPathFromIDList(pidl)
        except Exception, e:
            LOG.error("Failed to get directory: %s" % e)
            return None

        return str(fname)
filechooser.py 文件源码 项目:crisscross 作者: bhaveshAn 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def run(self):
        try:
            if self.mode != "dir":
                args = {}

                if self.path:
                    args["InitialDir"] = os.path.dirname(self.path)
                    path = os.path.splitext(os.path.dirname(self.path))
                    args["File"] = path[0]
                    args["DefExt"] = path[1]
                args["Title"] = self.title if self.title else "Pick a file..."
                args["CustomFilter"] = 'Other file types\x00*.*\x00'
                args["FilterIndex"] = 1

                filters = ""
                for f in self.filters:
                    if type(f) == str:
                        filters += (f + "\x00") * 2
                    else:
                        filters += f[0] + "\x00" + ";".join(f[1:]) + "\x00"
                args["Filter"] = filters

                flags = (win32con.OFN_EXTENSIONDIFFERENT |
                         win32con.OFN_OVERWRITEPROMPT)
                if self.multiple:
                    flags |= win32con.OFN_ALLOWmultiple | win32con.OFN_EXPLORER
                if self.show_hidden:
                    flags |= win32con.OFN_FORCESHOWHIDDEN
                args["Flags"] = flags

                if self.mode == "open":
                    self.fname, _, _ = win32gui.GetOpenFileNameW(**args)
                elif self.mode == "save":
                    self.fname, _, _ = win32gui.GetSaveFileNameW(**args)

                if self.fname:
                    if self.multiple:
                        seq = str(self.fname).split("\x00")
                        dir_n, base_n = seq[0], seq[1:]
                        self.selection = [os.path.join(dir_n, i)
                                          for i in base_n]
                    else:
                        self.selection = str(self.fname).split("\x00")
            else:
                # From http://goo.gl/UDqCqo
                pidl, display_name, image_list = shell.SHBrowseForFolder(
                    win32gui.GetDesktopWindow(),
                    None,
                    self.title if self.title else "Pick a folder...",
                    0, None, None
                )
                self.selection = [str(shell.SHGetPathFromIDList(pidl))]

            return self.selection
        except (RuntimeError, pywintypes.error):
            return None


问题


面经


文章

微信
公众号

扫码关注公众号