瀏覽代碼

wxGUI/map display: manage wx.StatusBar widget by AUI (#1646)

Needed for single layout, map display will not be always a wx.frame
Linda Kladivova 3 年之前
父節點
當前提交
c48a2dd358
共有 3 個文件被更改,包括 34 次插入13 次删除
  1. 2 2
      gui/wxpython/lmgr/giface.py
  2. 32 3
      gui/wxpython/mapdisp/frame.py
  3. 0 8
      gui/wxpython/mapdisp/statusbar.py

+ 2 - 2
gui/wxpython/lmgr/giface.py

@@ -259,10 +259,10 @@ class LayerManagerGrassInterface(object):
         self.lmgr.goutput.GetPrompt().UpdateCmdHistory(cmd)
 
     def ShowStatusbar(self, show=True):
-        self.lmgr.GetMapDisplay().statusbarManager.Show(show)
+        self.lmgr.GetMapDisplay().ShowStatusbar(show)
 
     def IsStatusbarShown(self):
-        return self.lmgr.GetMapDisplay().statusbarManager.IsShown()
+        return self.lmgr.GetMapDisplay().IsStatusbarShown()
 
     def ShowAllToolbars(self, show=True):
         if not show:  # hide

+ 32 - 3
gui/wxpython/mapdisp/frame.py

@@ -150,7 +150,7 @@ class MapFrame(SingleMapFrame):
         #
         self.statusbarManager = None
         if statusbar:
-            self.CreateStatusbar()
+            self.statusbar = self.CreateStatusbar()
 
         # init decoration objects
         self.decorations = {}
@@ -212,6 +212,21 @@ class MapFrame(SingleMapFrame):
             .DestroyOnClose(True)
             .Layer(0),
         )
+
+        self._mgr.AddPane(
+            self.statusbar,
+            wx.aui.AuiPaneInfo()
+            .Bottom()
+            .MinSize(30, 30)
+            .Fixed()
+            .Name("statusbar")
+            .CloseButton(False)
+            .DestroyOnClose(True)
+            .ToolbarPane()
+            .Dockable(False)
+            .PaneBorder(False)
+            .Gripper(False),
+        )
         self._mgr.Update()
 
         #
@@ -265,9 +280,9 @@ class MapFrame(SingleMapFrame):
             sb.SbMapScale,
         )
 
-        # create statusbar and its manager
-        statusbar = self.CreateStatusBar(number=4, style=0)
+        statusbar = wx.StatusBar(self, id=wx.ID_ANY)
         statusbar.SetMinHeight(24)
+        statusbar.SetFieldsCount(4)
         statusbar.SetStatusWidths([-5, -2, -1, -1])
         self.statusbarManager = sb.SbManager(mapframe=self, statusbar=statusbar)
 
@@ -293,6 +308,20 @@ class MapFrame(SingleMapFrame):
                 % dict(command=" ".join(cmd), error=error)
             )
         )
+        return statusbar
+
+    def ShowStatusbar(self, show):
+        """Show/hide statusbar and associated pane"""
+        self._mgr.GetPane("statusbar").Show(show)
+        self._mgr.Update()
+
+    def IsStatusbarShown(self):
+        """Check if statusbar is shown"""
+        return self._mgr.GetPane("statusbar").IsShown()
+
+    def SetStatusText(self, *args):
+        """Overide wx.StatusBar method"""
+        self.statusbar.SetStatusText(*args)
 
     def GetMapWindow(self):
         return self.MapWindow

+ 0 - 8
gui/wxpython/mapdisp/statusbar.py

@@ -330,14 +330,6 @@ class SbManager:
         if text:
             self.statusbar.SetStatusText(text)
 
-    def Show(self, show=True):
-        """Show/hide statusbar"""
-        self.statusbar.Show(show)
-
-    def IsShown(self):
-        """Check if statusbar is shown"""
-        return self.statusbar.IsShown()
-
 
 class SbItem:
     """Base class for statusbar items.