I am using the FileDialog class within TraitsUI, which works pretty well, except for the life of me, I have not been able to figure out how to pass a default directory, for the dialogue to use.
Ideally, the dialogue box would open at a point in the local file system other than the top of the tree...
Any insight or direction very gratefully appreciated from a newbie.
Base code pretty generic/standard as follows.
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