Python的JFileChooser?

2024-09-30 22:18:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我想知道是否有类似于Java针对Python的JFileChooser?在

JFileChooser是选择文件的图形前端。在

最好是Python中已有的东西。也许和特金特一起。在


Tags: 文件图形javajfilechooser
3条回答

对于不需要wxPython并坚持使用标准Python库的东西,可以使用tkFileDialog.askopenfilename()方法:

#!/usr/bin/python

from Tkinter import *
from tkFileDialog import askopenfilename

root = Tk()
root.withdraw()
print askopenfilename()

wxPython公司(www.wxpython.org)提供wx.FileDialog类,它将在任何受支持的平台(Mac、Linux或Windows)上为您提供本机文件选择对话框。在

最简单的方法是(使用PyGTK和Kiwi):

from kiwi.ui.dialogs import open as open_dialog

chosen_path = open_dialog('Select a file', folder='/start/folder')

if chosen_path is not None:
    # do something ...

相关问题 更多 >