python类OFN_FILEMUSTEXIST的实例源码

tlbrowse.py 文件源码 项目:OSPTF 作者: xSploited 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def OnFileOpen(self, id, code):
        openFlags = win32con.OFN_OVERWRITEPROMPT | win32con.OFN_FILEMUSTEXIST
        fspec = "Type Libraries (*.tlb, *.olb)|*.tlb;*.olb|OCX Files (*.ocx)|*.ocx|DLL's (*.dll)|*.dll|All Files (*.*)|*.*||"
        dlg = win32ui.CreateFileDialog(1, None, None, openFlags, fspec)
        if dlg.DoModal() == win32con.IDOK:
            try:
                self.tlb = pythoncom.LoadTypeLib(dlg.GetPathName())
            except pythoncom.ole_error:
                self.MessageBox("The file does not contain type information")
                self.tlb = None
            self._SetupTLB()
tlbrowse.py 文件源码 项目:pupy 作者: ru-faraon 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def OnFileOpen(self, id, code):
        openFlags = win32con.OFN_OVERWRITEPROMPT | win32con.OFN_FILEMUSTEXIST
        fspec = "Type Libraries (*.tlb, *.olb)|*.tlb;*.olb|OCX Files (*.ocx)|*.ocx|DLL's (*.dll)|*.dll|All Files (*.*)|*.*||"
        dlg = win32ui.CreateFileDialog(1, None, None, openFlags, fspec)
        if dlg.DoModal() == win32con.IDOK:
            try:
                self.tlb = pythoncom.LoadTypeLib(dlg.GetPathName())
            except pythoncom.ole_error:
                self.MessageBox("The file does not contain type information")
                self.tlb = None
            self._SetupTLB()
dialogs_legacy.py 文件源码 项目:inter 作者: rsms 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def GetFile(message=None):
    """
    Select file dialog. Returns path if one is selected. Otherwise it returns None.
    Availability: FontLab, Macintosh, PC
    """
    path = None
    if MAC:
        if haveMacfs:
            fss, ok = macfs.PromptGetFile(message)
            if ok:
                path = fss.as_pathname()
        else:
            from robofab.interface.mac.getFileOrFolder import GetFile
            path = GetFile(message)
    elif PC:
        if inFontLab:
            if not message:
                message = ''
            path = fl.GetFileName(1, message, '', '')
        else:
            openFlags = win32con.OFN_FILEMUSTEXIST|win32con.OFN_EXPLORER
            mode_open = 1
            myDialog = win32ui.CreateFileDialog(mode_open,None,None,openFlags)
            myDialog.SetOFNTitle(message)
            is_OK = myDialog.DoModal()
            if is_OK == 1:
                path = myDialog.GetPathName()
    else:
        _raisePlatformError('GetFile')
    return path
regsetup.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def LocateFileName(fileNamesString, searchPaths):
    """Locate a file name, anywhere on the search path.

       If the file can not be located, prompt the user to find it for us
       (using a common OpenFile dialog)

       Raises KeyboardInterrupt if the user cancels.
    """
    import regutil, string, os
    fileNames = fileNamesString.split(";")
    for path in searchPaths:
        for fileName in fileNames:
            try:
                retPath = os.path.join(path, fileName)
                os.stat(retPath)
                break
            except os.error:
                retPath = None
        if retPath:
            break
    else:
        fileName = fileNames[0]
        try:
            import win32ui, win32con
        except ImportError:
            raise error("Need to locate the file %s, but the win32ui module is not available\nPlease run the program again, passing as a parameter the path to this file." % fileName)
        # Display a common dialog to locate the file.
        flags=win32con.OFN_FILEMUSTEXIST
        ext = os.path.splitext(fileName)[1]
        filter = "Files of requested type (*%s)|*%s||" % (ext,ext)
        dlg = win32ui.CreateFileDialog(1,None,fileName,flags,filter,None)
        dlg.SetOFNTitle("Locate " + fileName)
        if dlg.DoModal() != win32con.IDOK:
            raise KeyboardInterrupt("User cancelled the process")
        retPath = dlg.GetPathName()
    return os.path.abspath(retPath)
tlbrowse.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def OnFileOpen(self, id, code):
        openFlags = win32con.OFN_OVERWRITEPROMPT | win32con.OFN_FILEMUSTEXIST
        fspec = "Type Libraries (*.tlb, *.olb)|*.tlb;*.olb|OCX Files (*.ocx)|*.ocx|DLL's (*.dll)|*.dll|All Files (*.*)|*.*||"
        dlg = win32ui.CreateFileDialog(1, None, None, openFlags, fspec)
        if dlg.DoModal() == win32con.IDOK:
            try:
                self.tlb = pythoncom.LoadTypeLib(dlg.GetPathName())
            except pythoncom.ole_error:
                self.MessageBox("The file does not contain type information")
                self.tlb = None
            self._SetupTLB()
regsetup.py 文件源码 项目:CodeReader 作者: jasonrbr 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def LocateFileName(fileNamesString, searchPaths):
    """Locate a file name, anywhere on the search path.

       If the file can not be located, prompt the user to find it for us
       (using a common OpenFile dialog)

       Raises KeyboardInterrupt if the user cancels.
    """
    import regutil, string, os
    fileNames = fileNamesString.split(";")
    for path in searchPaths:
        for fileName in fileNames:
            try:
                retPath = os.path.join(path, fileName)
                os.stat(retPath)
                break
            except os.error:
                retPath = None
        if retPath:
            break
    else:
        fileName = fileNames[0]
        try:
            import win32ui, win32con
        except ImportError:
            raise error("Need to locate the file %s, but the win32ui module is not available\nPlease run the program again, passing as a parameter the path to this file." % fileName)
        # Display a common dialog to locate the file.
        flags=win32con.OFN_FILEMUSTEXIST
        ext = os.path.splitext(fileName)[1]
        filter = "Files of requested type (*%s)|*%s||" % (ext,ext)
        dlg = win32ui.CreateFileDialog(1,None,fileName,flags,filter,None)
        dlg.SetOFNTitle("Locate " + fileName)
        if dlg.DoModal() != win32con.IDOK:
            raise KeyboardInterrupt("User cancelled the process")
        retPath = dlg.GetPathName()
    return os.path.abspath(retPath)
tlbrowse.py 文件源码 项目:CodeReader 作者: jasonrbr 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def OnFileOpen(self, id, code):
        openFlags = win32con.OFN_OVERWRITEPROMPT | win32con.OFN_FILEMUSTEXIST
        fspec = "Type Libraries (*.tlb, *.olb)|*.tlb;*.olb|OCX Files (*.ocx)|*.ocx|DLL's (*.dll)|*.dll|All Files (*.*)|*.*||"
        dlg = win32ui.CreateFileDialog(1, None, None, openFlags, fspec)
        if dlg.DoModal() == win32con.IDOK:
            try:
                self.tlb = pythoncom.LoadTypeLib(dlg.GetPathName())
            except pythoncom.ole_error:
                self.MessageBox("The file does not contain type information")
                self.tlb = None
            self._SetupTLB()


问题


面经


文章

微信
公众号

扫码关注公众号