Python win32con 模块,OFN_FILEMUSTEXIST 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用win32con.OFN_FILEMUSTEXIST

项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
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()
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
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()
项目:inter    作者:rsms    | 项目源码 | 文件源码
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
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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()
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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()