@@ -264,18 +264,11 @@ def OnwxPythonVersionChanged(self, event):
264264
265265 ### if ini file exist we remove old section and option
266266 if os .path .exists (path ):
267- try :
267+ if parser . has_option ( section , option ) :
268268 parser .remove_option (section , option )
269- except :
270- pass
271- try :
269+ if parser .has_section (section ):
272270 parser .remove_section (section )
273- except :
274- pass
275- try :
276- parser .add_section (section )
277- except :
278- pass
271+ parser .add_section (section )
279272
280273 if not parser .has_section (section ):
281274 parser .add_section (section )
@@ -400,21 +393,15 @@ def InitUI(self):
400393 def OnAbout (self , evt ):
401394 """ Search doc directory into 'doc' directory of DEVS package
402395 """
403- ### DEVS package
404396 choice = self .cb3 .GetValue ()
397+ doc_path = os .path .join (os .path .dirname (getattr (builtins , 'DEVS_DIR_PATH_DICT' ).get (choice )), 'doc' , 'index.html' )
405398
406- ### possible path of doc directory
407- path = os .path .join (os .path .dirname (getattr (builtins ,'DEVS_DIR_PATH_DICT' ).get (choice )), 'doc' , 'index.html' )
408-
409- ### Html frame
410- frame = HtmlFrame (self , wx .NewIdRef (), "Doc" , (600 ,600 ))
411- ### if page exist in <package_dir>/<doc>
412- if os .path .exists (path ):
413- frame .LoadFile (path )
399+ frame = HtmlFrame (self , wx .NewIdRef (), "Doc" , (600 , 600 ))
400+ if os .path .exists (doc_path ):
401+ frame .LoadFile (doc_path )
414402 else :
415- frame .SetPage (_ ("<p> %s documentation directory not found! <p>" )% choice )
403+ frame .SetPage (_ ("<p> %s documentation directory not found! <p>" ) % choice )
416404
417- ### Show frame
418405 frame .Show ()
419406
420407 def OnSelectSound (self , evt ):
@@ -463,8 +450,7 @@ def onCb1Check(self, evt):
463450 def onCb4 (self , evt ):
464451 """ ComboBox has been checked.
465452 """
466- val = evt .GetEventObject ().GetValue ()
467- self .sim_defaut_strategy = val
453+ self .sim_defaut_strategy = evt .GetEventObject ().GetValue ()
468454
469455 def onCb3 (self , evt ):
470456 """ ComboBox has been checked.
@@ -490,8 +476,7 @@ def onCb3(self, evt):
490476 def onSc (self , evt ):
491477 """ CheckBox has been checked.
492478 """
493- val = evt .GetEventObject ().GetValue ()
494- self .sim_defaut_plot_dyn_freq = val
479+ self .sim_defaut_plot_dyn_freq = evt .GetEventObject ().GetValue ()
495480
496481 def OnApply (self , evt ):
497482 """ Apply changes.
@@ -559,11 +544,7 @@ def InitUI(self):
559544 choices = []
560545
561546 for editor in EditorPanel .EDITORS :
562- try :
563- importlib .import_module (editor )
564- except :
565- pass
566- else :
547+ if importlib .util .find_spec (editor ) is not None :
567548 choices .append (editor )
568549
569550 ### add the choice object to select one external code editor
@@ -602,17 +583,16 @@ def OnUpdateExternalEditors(self, event):
602583 """ Update Button has been clicked in order to update the list of available external editors.
603584 """
604585
605- installed = False
586+ installed_editors = []
606587 for editor in EditorPanel .EDITORS :
607588 if self .choice .FindString (editor ) == wx .NOT_FOUND and BuzyCursorNotification (install (editor )):
608- installed = True
609- items = self .choice .GetItems ()+ [editor ]
610- self .choice .SetItems (items )
589+ installed_editors .append (editor )
611590
612- if installed :
613- msg = _ ('You need to restart DEVSimPy to use the new installed code editor.' )
591+ if installed_editors :
592+ self .choice .AppendItems (installed_editors )
593+ msg = _ ('You need to restart DEVSimPy to use the newly installed code editor(s).' )
614594 else :
615- msg = _ ('All external editors are installed.' )
595+ msg = _ ('All external editors are already installed.' )
616596
617597 dial = wx .MessageDialog (self .parent , msg , _ ("External Code Editor Installation" ), wx .OK | wx .ICON_INFORMATION )
618598 dial .ShowModal ()
0 commit comments