我在TraitsUI中使用FileDialog类,它工作得很好,除了我的生活,我还没有能够弄清楚如何通过默认目录,for要使用的对话。在Traits中添加默认文件目录到FileDialog
理想的情况下,对话框将在比树的顶部以外的本地文件系统的一个点开...
任何有识之士或者方向从一个新手很感激地赞赏。
基本代码相当通用/标准如下。
demo_id = 'traitsui.demo.standard_editors.file_dialog.file_info'
class FileDialog (HasTraits):
# The name of the selected file:
file_name = File
# The button used to display the file dialog:
open = Button('Open...')
#-- Traits View Definitions ------------------------------------------------
view = View(
HGroup(
Item('open', show_label = False),
'_',
Item('file_name', style = 'readonly', springy = True)
),
width = 0.5
)
#-- Traits Event Handlers --------------------------------------------------
def _open_changed (self):
""" Handles the user clicking the 'Open...' button.
"""
file_name = open_file(extensions = FileInfo(), id = demo_id)
if file_name != '':
self.file_name = file_name
这是API https://svn.enthought.com/enthought/wiki/FileDialogDemo – aestrivex 2015-02-04 19:49:42
感谢更有用的描述,良好的点https://github.com/enthought/pyface/issues/119 – 2015-02-04 19:59:01