@@ -234,7 +234,6 @@ def __init__(self, parent, title,
234234 """
235235 Initialize the Frame object
236236 """
237-
238237 PARENT_FRAME .__init__ (self , parent = parent , title = title , pos = pos , size = size )
239238 # title
240239 self .title = title
@@ -363,7 +362,7 @@ def put_icon(self, frame):
363362 icon = self .GetIcon ()
364363 frame .SetIcon (icon )
365364 except :
366- pass
365+ logging . error ( "ViewerFrame.put_icon: could not set icon" )
367366
368367 def get_client_size (self ):
369368 """
@@ -751,7 +750,6 @@ def reset_bookmark_menu(self, panel):
751750 wx .EVT_MENU (self , id , cpanel ._back_to_bookmark )
752751 self ._toolbar .Realize ()
753752
754-
755753 def build_gui (self ):
756754 """
757755 Build the GUI by setting up the toolbar, menu and layout.
@@ -778,7 +776,6 @@ def build_gui(self):
778776 # Append item from plugin under menu file if necessary
779777 self ._populate_file_menu ()
780778
781-
782779 if not wx .VERSION_STRING >= '3.0.0.0' :
783780 self .SetMenuBar (self ._menubar )
784781
@@ -821,7 +818,6 @@ def _setup_layout(self):
821818 self .SetStatusBar (self .sb )
822819 # Load panels
823820 self ._load_panels ()
824- self .set_default_perspective ()
825821
826822 def SetStatusText (self , * args , ** kwds ):
827823 """
@@ -930,11 +926,7 @@ def _find_plugins(self, dir="perspectives"):
930926 module = imp .load_module (name , file , item , info )
931927 if hasattr (module , "PLUGIN_ID" ):
932928 try :
933- plug = module .Plugin ()
934- if plug .set_default_perspective ():
935- self ._current_perspective = plug
936- plugins .append (plug )
937-
929+ plugins .append (module .Plugin ())
938930 msg = "Found plug-in: %s" % module .PLUGIN_ID
939931 logging .info (msg )
940932 except :
@@ -1510,42 +1502,42 @@ def _populate_file_menu(self):
15101502 if len (plugin .populate_file_menu ()) > 0 :
15111503 for item in plugin .populate_file_menu ():
15121504 m_name , m_hint , m_handler = item
1513- id = wx .NewId ()
1514- self ._file_menu .Append (id , m_name , m_hint )
1515- wx .EVT_MENU (self , id , m_handler )
1505+ wx_id = wx .NewId ()
1506+ self ._file_menu .Append (wx_id , m_name , m_hint )
1507+ wx .EVT_MENU (self , wx_id , m_handler )
15161508 self ._file_menu .AppendSeparator ()
15171509
15181510 style1 = self .__gui_style & GUIFRAME .MULTIPLE_APPLICATIONS
15191511 if OPEN_SAVE_MENU :
1520- id = wx .NewId ()
1512+ wx_id = wx .NewId ()
15211513 hint_load_file = "read all analysis states saved previously"
1522- self ._save_appl_menu = self ._file_menu .Append (id , '&Open Project' , hint_load_file )
1523- wx .EVT_MENU (self , id , self ._on_open_state_project )
1514+ self ._save_appl_menu = self ._file_menu .Append (wx_id , '&Open Project' , hint_load_file )
1515+ wx .EVT_MENU (self , wx_id , self ._on_open_state_project )
15241516
15251517 if style1 == GUIFRAME .MULTIPLE_APPLICATIONS :
15261518 # some menu of plugin to be seen under file menu
15271519 hint_load_file = "Read a status files and load"
15281520 hint_load_file += " them into the analysis"
1529- id = wx .NewId ()
1530- self ._save_appl_menu = self ._file_menu .Append (id ,
1521+ wx_id = wx .NewId ()
1522+ self ._save_appl_menu = self ._file_menu .Append (wx_id ,
15311523 '&Open Analysis' , hint_load_file )
1532- wx .EVT_MENU (self , id , self ._on_open_state_application )
1524+ wx .EVT_MENU (self , wx_id , self ._on_open_state_application )
15331525 if OPEN_SAVE_MENU :
15341526 self ._file_menu .AppendSeparator ()
1535- id = wx .NewId ()
1536- self ._file_menu .Append (id , '&Save Project' ,
1527+ wx_id = wx .NewId ()
1528+ self ._file_menu .Append (wx_id , '&Save Project' ,
15371529 'Save the state of the whole analysis' )
1538- wx .EVT_MENU (self , id , self ._on_save_project )
1530+ wx .EVT_MENU (self , wx_id , self ._on_save_project )
15391531 if style1 == GUIFRAME .MULTIPLE_APPLICATIONS :
1540- id = wx .NewId ()
1541- self ._save_appl_menu = self ._file_menu .Append (id , \
1532+ wx_id = wx .NewId ()
1533+ self ._save_appl_menu = self ._file_menu .Append (wx_id , \
15421534 '&Save Analysis' , 'Save state of the current active analysis panel' )
1543- wx .EVT_MENU (self , id , self ._on_save_application )
1535+ wx .EVT_MENU (self , wx_id , self ._on_save_application )
15441536 if not sys .platform == 'darwin' :
15451537 self ._file_menu .AppendSeparator ()
1546- id = wx .NewId ()
1547- self ._file_menu .Append (id , '&Quit' , 'Exit' )
1548- wx .EVT_MENU (self , id , self .Close )
1538+ wx_id = wx .NewId ()
1539+ self ._file_menu .Append (wx_id , '&Quit' , 'Exit' )
1540+ wx .EVT_MENU (self , wx_id , self .Close )
15491541
15501542 def _add_menu_file (self ):
15511543 """
@@ -1716,12 +1708,9 @@ def create_gui_data(self, data, path=None):
17161708 def get_data (self , path ):
17171709 """
17181710 """
1719- message = ""
17201711 log_msg = ''
1721- output = []
1722- error_message = ""
17231712 basename = os .path .basename (path )
1724- root , extension = os .path .splitext (basename )
1713+ _ , extension = os .path .splitext (basename )
17251714 if extension .lower () not in EXTENSIONS :
17261715 log_msg = "File Loader cannot "
17271716 log_msg += "load: %s\n " % str (basename )
@@ -2224,18 +2213,6 @@ def post_init(self):
22242213 if hasattr (item , "post_init" ):
22252214 item .post_init ()
22262215
2227- def set_default_perspective (self ):
2228- """
2229- Choose among the plugin the first plug-in that has
2230- "set_default_perspective" method and its return value is True will be
2231- as a default perspective when the welcome page is closed
2232- """
2233- for item in self .plugins :
2234- if hasattr (item , "set_default_perspective" ):
2235- if item .set_default_perspective ():
2236- item .on_perspective (event = None )
2237- return
2238-
22392216 def set_perspective (self , panels ):
22402217 """
22412218 Sets the perspective of the GUI.
@@ -2413,13 +2390,12 @@ def remove_data(self, data_id, theory_id=None):
24132390 theory_data , theory_state = item
24142391 total_plot_list .append (theory_data )
24152392 for new_plot in total_plot_list :
2416- id = new_plot .id
24172393 for group_id in new_plot .list_group_id :
2418- wx .PostEvent (self , NewPlotEvent (id = id ,
2394+ wx .PostEvent (self , NewPlotEvent (id = new_plot . id ,
24192395 group_id = group_id ,
24202396 action = 'remove' ))
24212397 #remove res plot: Todo: improve
2422- wx .CallAfter (self ._remove_res_plot , id )
2398+ wx .CallAfter (self ._remove_res_plot , new_plot . id )
24232399 self ._data_manager .delete_data (data_id = data_id ,
24242400 theory_id = theory_id )
24252401
@@ -2454,26 +2430,26 @@ def save_data1d(self, data, fname):
24542430 # This is MAC Fix
24552431 ext_num = dlg .GetFilterIndex ()
24562432 if ext_num == 0 :
2457- format = '.txt'
2433+ ext_format = '.txt'
24582434 else :
2459- format = '.xml'
2460- path = os .path .splitext (path )[0 ] + format
2435+ ext_format = '.xml'
2436+ path = os .path .splitext (path )[0 ] + ext_format
24612437 mypath = os .path .basename (path )
24622438
24632439 #Instantiate a loader
24642440 loader = Loader ()
2465- format = ".txt"
2466- if os .path .splitext (mypath )[1 ].lower () == format :
2441+ ext_format = ".txt"
2442+ if os .path .splitext (mypath )[1 ].lower () == ext_format :
24672443 # Make sure the ext included in the file name
24682444 # especially on MAC
2469- fName = os .path .splitext (path )[0 ] + format
2445+ fName = os .path .splitext (path )[0 ] + ext_format
24702446 self ._onsaveTXT (data , fName )
2471- format = ".xml"
2472- if os .path .splitext (mypath )[1 ].lower () == format :
2447+ ext_format = ".xml"
2448+ if os .path .splitext (mypath )[1 ].lower () == ext_format :
24732449 # Make sure the ext included in the file name
24742450 # especially on MAC
2475- fName = os .path .splitext (path )[0 ] + format
2476- loader .save (fName , data , format )
2451+ fName = os .path .splitext (path )[0 ] + ext_format
2452+ loader .save (fName , data , ext_format )
24772453 try :
24782454 self ._default_save_location = os .path .dirname (path )
24792455 except :
@@ -2597,21 +2573,21 @@ def save_data2d(self, data, fname):
25972573 # This is MAC Fix
25982574 ext_num = dlg .GetFilterIndex ()
25992575 if ext_num == 0 :
2600- format = '.dat'
2576+ ext_format = '.dat'
26012577 else :
2602- format = ''
2603- path = os .path .splitext (path )[0 ] + format
2578+ ext_format = ''
2579+ path = os .path .splitext (path )[0 ] + ext_format
26042580 mypath = os .path .basename (path )
26052581
26062582 #Instantiate a loader
26072583 loader = Loader ()
26082584
2609- format = ".dat"
2610- if os .path .splitext (mypath )[1 ].lower () == format :
2585+ ext_format = ".dat"
2586+ if os .path .splitext (mypath )[1 ].lower () == ext_format :
26112587 # Make sure the ext included in the file name
26122588 # especially on MAC
2613- fileName = os .path .splitext (path )[0 ] + format
2614- loader .save (fileName , data , format )
2589+ fileName = os .path .splitext (path )[0 ] + ext_format
2590+ loader .save (fileName , data , ext_format )
26152591 try :
26162592 self ._default_save_location = os .path .dirname (path )
26172593 except :
@@ -3205,9 +3181,9 @@ def __init__(self, parent, *args, **kwds):
32053181
32063182
32073183
3208- class ViewApp (wx .App ):
3184+ class SasViewApp (wx .App ):
32093185 """
3210- Toy application to test this Frame
3186+ SasView application
32113187 """
32123188 def OnInit (self ):
32133189 """
@@ -3293,8 +3269,8 @@ def clean_plugin_models(self, path):
32933269 if os .path .exists (model_folder ) and os .path .isdir (model_folder ):
32943270 if len (os .listdir (model_folder )) > 0 :
32953271 try :
3296- for file in os .listdir (model_folder ):
3297- file_path = os .path .join (model_folder , file )
3272+ for filename in os .listdir (model_folder ):
3273+ file_path = os .path .join (model_folder , filename )
32983274 if os .path .isfile (file_path ):
32993275 os .remove (file_path )
33003276 except :
@@ -3313,10 +3289,7 @@ def build_gui(self):
33133289 Build the GUI
33143290 """
33153291 #try to load file at the start
3316- try :
3317- self .open_file ()
3318- except :
3319- raise
3292+ self .open_file ()
33203293 self .frame .build_gui ()
33213294
33223295 def set_welcome_panel (self , panel_class ):
0 commit comments