99from pyface .tasks .action .api import DockPaneToggleGroup , SGroup , SMenu , \
1010 SMenuBar , SToolBar , TaskAction , TaskWindowAction
1111
12- from traits .api import HasStrictTraits , File
12+ from traits .api import Bool , HasStrictTraits , File
1313from traitsui .api import Item , OKCancelButtons , View
1414from pycasa .ui .image_resources import app_icon
1515
@@ -64,14 +64,19 @@ def open_in_central_pane(self, filepath):
6464 self .central_pane .edit (obj , factory = ImageFolderEditor )
6565 else :
6666 print ("Unsupported file format: {}" .format (file_ext ))
67+ obj = None
68+
69+ return obj
6770
6871 # Menu action methods -----------------------------------------------------
6972
7073 def request_open_new_path (self ):
7174 selector = PathSelector ()
7275 ui = selector .edit_traits (kind = "livemodal" )
7376 if ui .result :
74- self .open_in_central_pane (selector .filepath )
77+ obj = self .open_in_central_pane (selector .filepath )
78+ if obj and selector .do_scan :
79+ self ._scan_model (obj )
7580
7681 def scan_current_path (self ):
7782 if self .central_pane .active_editor is None :
@@ -82,7 +87,9 @@ def scan_current_path(self):
8287
8388 active_editor = self .central_pane .active_editor
8489 model = active_editor .obj
90+ self ._scan_model (model )
8591
92+ def _scan_model (self , model ):
8693 self .status_bar .messages = ["Scanning..." ]
8794
8895 if isinstance (model , ImageFolder ):
@@ -162,7 +169,10 @@ def _status_bar_default(self):
162169class PathSelector (HasStrictTraits ):
163170 filepath = File
164171
172+ scan_for_faces = Bool
173+
165174 view = View (Item ("filepath" ),
175+ Item ("scan_for_faces" ),
166176 resizable = True ,
167177 icon = app_icon ,
168178 width = 400 , height = 200 ,
0 commit comments