[Python] How can I use a wx.FileDialog to select a file which is locked by another process

Discussão em 'Python' iniciado por Stack, Maio 5, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to use the wx.FileDialog class to select the name of a file. I don't want to open it. This is a minimal example of what I'm trying to do:

    import wx

    if __name__ == '__main__':
    app = wx.App(redirect=False)
    frame = wx.Frame(None)
    frame.Show()

    dlg = wx.FileDialog(parent=frame, style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST, wildcard="Project (*.ap*)|*.ap*|All files (*.*)|*.*")
    dlg.ShowModal()

    app.MainLoop()


    [​IMG]

    The text is in Swedish and says "File in use. Select a different name of close the file in use in another program".

    I'm trying to select the filename of a TIA Portal project file (Siemens PLC programming tool). Unfortunately it seems that TIA Portal locks the file. NOTE: I don't want to open the file. I just need the name.

    Continue reading...

Compartilhe esta Página