Browse Source

wxGUI Single-Window: Focus the Console pane when console content has been changed (#2121)

Linda Kladivova 3 years ago
parent
commit
64d3a85a55
1 changed files with 20 additions and 0 deletions
  1. 20 0
      gui/wxpython/main_window/frame.py

+ 20 - 0
gui/wxpython/main_window/frame.py

@@ -349,6 +349,9 @@ class GMFrame(wx.Frame):
         self.goutput.showNotification.connect(
             lambda message: self.SetStatusText(message)
         )
+        self.goutput.contentChanged.connect(
+            lambda notification: self._focusPage(notification)
+        )
 
         self._gconsole.mapCreated.connect(self.OnMapCreated)
         self._gconsole.Bind(
@@ -947,6 +950,23 @@ class GMFrame(wx.Frame):
         )
         self.mapnotebook.DeletePage(pgnum_dict["mapnotebook"])
 
+    def _focusPage(self, notification):
+        """Focus the 'Console' notebook page according to event notification."""
+        if (
+            notification == Notification.HIGHLIGHT
+            or notification == Notification.MAKE_VISIBLE
+            or notification == Notification.RAISE_WINDOW
+        ):
+            self.FocusPage("Console")
+
+    def FocusPage(self, page_text):
+        """Focus the page if part of any of aui notebooks"""
+        notebooks = self._auimgr.GetNotebooks()
+        for notebook in notebooks:
+            for i in range(notebook.GetPageCount()):
+                if notebook.GetPageText(i) == page_text:
+                    notebook.SetSelection(i)
+
     def RunSpecialCmd(self, command):
         """Run command from command line, check for GUI wrappers"""
         if re.compile(r"^d\..*").search(command[0]):