Parcourir la source

wxGUI r.li.setup: Show message dialog if removed config file isn't selected from the list (#631)

* wxGUI g.gui.rlisetup: show message dialog if removed config file isn't selected from the list

* wxGUI g.gui.rlisetup: specify exception type
Tomas Zigo il y a 5 ans
Parent
commit
bbe3d3e2a5
1 fichiers modifiés avec 8 ajouts et 3 suppressions
  1. 8 3
      gui/wxpython/rlisetup/frame.py

+ 8 - 3
gui/wxpython/rlisetup/frame.py

@@ -218,7 +218,12 @@ class RLiSetupFrame(wx.Frame):
 
     def OnRemove(self, event):
         """Remove configuration file from path and update the list"""
-        confile = self.listfiles[self.listfileBox.GetSelections()[0]]
+        try:
+            confile = self.listfiles[self.listfileBox.GetSelections()[0]]
+        except IndexError:
+            gcmd.GMessage(parent=self,
+                          message=_("You have to select a configuration file"))
+            return
         dlg = wx.MessageDialog(
             parent=self.parent,
             message=_(
@@ -246,7 +251,7 @@ class RLiSetupFrame(wx.Frame):
         """Rename an existing configuration file"""
         try:
             confile = self.listfiles[self.listfileBox.GetSelections()[0]]
-        except:
+        except IndexError:
             gcmd.GMessage(parent=self,
                           message=_("You have to select a configuration file"))
             return
@@ -266,7 +271,7 @@ class RLiSetupFrame(wx.Frame):
         """Show and edit a configuration file"""
         try:
             confile = self.listfiles[self.listfileBox.GetSelections()[0]]
-        except:
+        except IndexError:
             gcmd.GMessage(parent=self,
                           message=_("You have to select a configuration file"))
             return