[GRASS-SVN] r71975 - grass/trunk/gui/wxpython/startup

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Dec 26 11:38:11 PST 2017


Author: martinl
Date: 2017-12-26 11:38:11 -0800 (Tue, 26 Dec 2017)
New Revision: 71975

Modified:
   grass/trunk/gui/wxpython/startup/locdownload.py
Log:
wxGUI/downloc: add message for asking user to abort download process

Modified: grass/trunk/gui/wxpython/startup/locdownload.py
===================================================================
--- grass/trunk/gui/wxpython/startup/locdownload.py	2017-12-26 12:17:25 UTC (rev 71974)
+++ grass/trunk/gui/wxpython/startup/locdownload.py	2017-12-26 19:38:11 UTC (rev 71975)
@@ -360,6 +360,7 @@
             self._warning(_("Download in progress, wait until it is finished"))
         index = self.choice.GetSelection()
         self.DownloadItem(self.locations[index])
+        self.download_button.Enable(False)
 
     def DownloadItem(self, item):
         """Download the selected item"""
@@ -461,7 +462,7 @@
         self.panel = LocationDownloadPanel(parent=self, database=database)
         close_button = Button(self, id=wx.ID_CLOSE)
         # TODO: terminate download process
-        close_button.Bind(wx.EVT_BUTTON, lambda event: self.Close())
+        close_button.Bind(wx.EVT_BUTTON, self.OnClose)
 
         sizer = wx.BoxSizer(wx.VERTICAL)
         sizer.Add(self.panel, proportion=1, flag=wx.EXPAND)
@@ -481,7 +482,23 @@
         """Get the name of the last location downloaded by the user"""
         return self.panel.GetLocation()
 
+    def OnClose(self, event):
+        if self.panel.thread.GetId() > 1:
+            # running thread
+            dlg = wx.MessageDialog(parent=self,
+                                   message=_("Do you want to cancel location download?"),
+                                   caption=_("Abort download"),
+                                   style=wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION | wx.CENTRE
+            )
+            
+            ret = dlg.ShowModal()
+            dlg.Destroy()
 
+            if ret == wx.ID_NO:
+                return
+    
+        self.Close()
+
 def main():
     """Tests the download dialog"""
     if len(sys.argv) < 2:



More information about the grass-commit mailing list