浏览代码

wxGUI: fixed removing/inserting statusbar items when switching 2D/3D view

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@49003 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 13 年之前
父节点
当前提交
f9c0c9f62e
共有 1 个文件被更改,包括 13 次插入11 次删除
  1. 13 11
      gui/wxpython/gui_modules/mapdisp_statusbar.py

+ 13 - 11
gui/wxpython/gui_modules/mapdisp_statusbar.py

@@ -142,13 +142,17 @@ class SbManager:
         @see ShowStatusbarChoiceItemsByClass
         @todo consider adding similar function which would take item names
         """
+        index = []
         for itemClass in itemClasses:
             for i in range(0, self.choice.GetCount() - 1):
                 item = self.choice.GetClientData(i)
                 if item.__class__ == itemClass:
-                    self.choice.Delete(i)
-                    self._hiddenItems[item] = i
-                
+                    index.append(i)
+                    self._hiddenItems[i] = item
+        # must be sorted in reverse order to be removed correctly
+        for i in sorted(index, reverse = True):
+            self.choice.Delete(i)
+        
     def ShowStatusbarChoiceItemsByClass(self, itemClasses):
         """!Shows items showed in choice
         
@@ -160,14 +164,12 @@ class SbManager:
         
         @see HideStatusbarChoiceItemsByClass
         """
-        for itemClass in itemClasses:
-            for item in self.statusbarItems.values():
-                if item.__class__ == itemClass:
-                    if self.choice.FindString(item.label) != wx.NOT_FOUND:
-                        return # item already in choice
-                    pos = self._hiddenItems[item]
-                    self.choice.Insert(item.label, pos, item)
-                    
+        # must be sorted to be inserted correctly
+        for pos in sorted(self._hiddenItems.keys()):
+            item = self._hiddenItems[pos]
+            if item.__class__ in itemClasses:
+                self.choice.Insert(item.label, pos, item)
+        
     def ShowItem(self, itemName):
         """!Invokes showing of particular item