<s> from atom . api import Bool , Enum , List , Unicode , Typed , ForwardTyped , observe <EOL> from enaml . core . declarative import d_ <EOL> from . toolkit_dialog import ToolkitDialog , ProxyToolkitDialog <EOL> class ProxyFileDialogEx ( ProxyToolkitDialog ) : <EOL> """<STR_LIT>""" <EOL> declaration = ForwardTyped ( lambda : FileDialogEx ) <EOL> def set_accept_mode ( self , accept_mode ) : <EOL> raise NotImplementedError <EOL> def set_file_mode ( self , file_mode ) : <EOL> raise NotImplementedError <EOL> def set_show_dirs_only ( self , show ) : <EOL> raise NotImplementedError <EOL> def set_current_path ( self , path ) : <EOL> raise NotImplementedError <EOL> def set_name_filters ( self , filters ) : <EOL> raise NotImplementedError <EOL> def set_selected_name_filter ( self , selected ) : <EOL> raise NotImplementedError <EOL> def exec_native ( self ) : <EOL> raise NotImplementedError <EOL> class FileDialogEx ( ToolkitDialog ) : <EOL> """<STR_LIT>""" <EOL> accept_mode = d_ ( Enum ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> file_mode = d_ ( Enum ( <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> show_dirs_only = d_ ( Bool ( False ) ) <EOL> current_path = d_ ( Unicode ( ) ) <EOL> selected_paths = List ( Unicode ( ) ) <EOL> name_filters = d_ ( List ( Unicode ( ) ) ) <EOL> selected_name_filter = d_ ( Unicode ( ) ) <EOL> proxy = Typed ( ProxyFileDialogEx ) <EOL> @ staticmethod <EOL> def get_existing_directory ( parent = None , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> kwargs [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> kwargs [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> kwargs [ '<STR_LIT>' ] = True <EOL> dialog = FileDialogEx ( parent , ** kwargs ) <EOL> if dialog . exec_native ( ) : <EOL> if dialog . selected_paths : <EOL> return dialog . selected_paths [ <NUM_LIT:0> ] <EOL> return u'<STR_LIT>' <EOL> @ staticmethod <EOL> def get_open_file_name ( parent = None , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> kwargs [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> kwargs [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> dialog = FileDialogEx ( parent , ** kwargs ) <EOL> if dialog . exec_native ( ) : <EOL> if dialog . selected_paths : <EOL> return dialog . selected_paths [ <NUM_LIT:0> ] <EOL> return u'<STR_LIT>' <EOL> @ staticmethod <EOL> def get_open_file_names ( parent = None , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> kwargs [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> kwargs [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> dialog = FileDialogEx ( parent , ** kwargs ) <EOL> if dialog . exec_native ( ) : <EOL> return dialog . selected_paths <EOL> return [ ] <EOL> @ staticmethod <EOL> def get_save_file_name ( parent = None , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> kwargs [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> kwargs [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> dialog = FileDialogEx ( parent , ** kwargs ) <EOL> if dialog . exec_native ( ) : <EOL> if dialog . selected_paths : <EOL> return dialog . selected_paths [ <NUM_LIT:0> ] <EOL> return u'<STR_LIT>' <EOL> def exec_native ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . is_initialized : <EOL> self . initialize ( ) <EOL> if not self . proxy_is_active : <EOL> self . activate_proxy ( ) <EOL> self . _prepare ( ) <EOL> self . proxy . exec_native ( ) <EOL> return self . result <EOL> @ observe ( ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def _update_proxy ( self , change ) : <EOL> """<STR_LIT>""" <EOL> super ( FileDialogEx , self ) . _update_proxy ( change ) <EOL> def _prepare ( self ) : <EOL> """<STR_LIT>""" <EOL> super ( FileDialogEx , self ) . _prepare ( ) <EOL> self . selected_paths = [ ] <EOL> self . selected_name_filter = u'<STR_LIT>' </s>
