Which is the best way to interact with already open native OS dialog boxes like (Save AS) using Python?

前端 未结 2 714
难免孤独
难免孤独 2021-01-01 01:18

Is there any efficient way using any Python module like PyWind32 to interact with already existing Native OS dialog boxes like \'Save As\' boxes?

I trie

2条回答
  •  感情败类
    2021-01-01 02:11

    There is a Python module called win32ui. Its found in the Python for Windows extensions package. You want the CreateFileDialog function.

    Documentation

    Edit: This is a save dialog example. Check the documentation for the other settings.

    import win32ui
    
    if __name__ == "__main__":
        select_dlg = win32ui.CreateFileDialog(0, ".txt", "default_name", 0, "TXT Files (*.txt)|*.txt|All Files (*.*)|*.*|")
        select_dlg.DoModal()
    
        selected_file = select_dlg.GetPathName()
        print selected_file
    

提交回复
热议问题