فهرست منبع

wxGUI/extension: load data in different thread
(merge https://trac.osgeo.org/grass/changeset/61993 from trunk)


git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@62054 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 10 سال پیش
والد
کامیت
be80d81841
1فایلهای تغییر یافته به همراه9 افزوده شده و 3 حذف شده
  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.gcmd        import GError, RunCommand, GException, GMessage
 from core.utils       import SetAddOnPath, _
+from core.gthread import gThread
 from core.menutree    import TreeModel, ModuleNode
 from gui_core.widgets import GListCtrl, SearchModuleWidget
 from gui_core.treeview import CTreeView
@@ -63,6 +64,8 @@ class InstallExtensionWindow(wx.Frame):
         self.search.showSearchResult.connect(lambda result: self.tree.Select(result))
         # show text in statusbar when notification appears
         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,
                                       label = " %s " % _("Options"))
@@ -187,14 +190,17 @@ class InstallExtensionWindow(wx.Frame):
         wx.BeginBusyCursor()
         self.SetStatusText(_("Fetching list of modules from GRASS-Addons SVN (be patient)..."), 0)
         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:
+            self._fetchDone()
             GError(unicode(e), parent = self, showTraceback = False)
-        
+            
+    def _fetchDone(self):
         self.tree.RefreshItems()
         self.SetStatusText("", 0)
         wx.EndBusyCursor()
-
+        
     def OnContextMenu(self, node):
         if not hasattr (self, "popupID"):
             self.popupID = dict()