Browse Source

wxGUI/extension: load data in different thread

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@61993 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 10 years ago
parent
commit
b63cf5a326
1 changed files with 9 additions and 3 deletions
  1. 9 3
      gui/wxpython/modules/extensions.py

+ 9 - 3
gui/wxpython/modules/extensions.py

@@ -28,6 +28,7 @@ from grass.script import task as gtask
 from core             import globalvar
 from core             import globalvar
 from core.gcmd        import GError, RunCommand, GException, GMessage
 from core.gcmd        import GError, RunCommand, GException, GMessage
 from core.utils       import SetAddOnPath, _
 from core.utils       import SetAddOnPath, _
+from core.gthread import gThread
 from core.menutree    import TreeModel, ModuleNode
 from core.menutree    import TreeModel, ModuleNode
 from gui_core.widgets import GListCtrl, SearchModuleWidget
 from gui_core.widgets import GListCtrl, SearchModuleWidget
 from gui_core.treeview import CTreeView
 from gui_core.treeview import CTreeView
@@ -63,6 +64,8 @@ class InstallExtensionWindow(wx.Frame):
         self.search.showSearchResult.connect(lambda result: self.tree.Select(result))
         self.search.showSearchResult.connect(lambda result: self.tree.Select(result))
         # show text in statusbar when notification appears
         # show text in statusbar when notification appears
         self.search.showNotification.connect(lambda message: self.SetStatusText(message))
         self.search.showNotification.connect(lambda message: self.SetStatusText(message))
+        # load data in different thread
+        self.thread = gThread()
 
 
         self.optionBox = wx.StaticBox(parent = self.panel, id = wx.ID_ANY,
         self.optionBox = wx.StaticBox(parent = self.panel, id = wx.ID_ANY,
                                       label = " %s " % _("Options"))
                                       label = " %s " % _("Options"))
@@ -187,14 +190,17 @@ class InstallExtensionWindow(wx.Frame):
         wx.BeginBusyCursor()
         wx.BeginBusyCursor()
         self.SetStatusText(_("Fetching list of modules from GRASS-Addons SVN (be patient)..."), 0)
         self.SetStatusText(_("Fetching list of modules from GRASS-Addons SVN (be patient)..."), 0)
         try:
         try:
-            self.modelBuilder.Load(url = self.repo.GetValue().strip())
+            self.thread.Run(callable=self.modelBuilder.Load, url=self.repo.GetValue().strip(),
+                            ondone=lambda event: self._fetchDone())
         except GException as e:
         except GException as e:
+            self._fetchDone()
             GError(unicode(e), parent = self, showTraceback = False)
             GError(unicode(e), parent = self, showTraceback = False)
-        
+            
+    def _fetchDone(self):
         self.tree.RefreshItems()
         self.tree.RefreshItems()
         self.SetStatusText("", 0)
         self.SetStatusText("", 0)
         wx.EndBusyCursor()
         wx.EndBusyCursor()
-
+        
     def OnContextMenu(self, node):
     def OnContextMenu(self, node):
         if not hasattr (self, "popupID"):
         if not hasattr (self, "popupID"):
             self.popupID = dict()
             self.popupID = dict()