Browse Source

wxGUI/prompt: support dark themes (#1217)

Anna Petrasova 4 years ago
parent
commit
fd93011d71
1 changed files with 10 additions and 1 deletions
  1. 10 1
      gui/wxpython/gui_core/prompt.py

+ 10 - 1
gui/wxpython/gui_core/prompt.py

@@ -173,9 +173,18 @@ class GPromptSTC(GPrompt, wx.stc.StyledTextCtrl):
         self.SetViewWhiteSpace(False)
         self.SetUseTabs(False)
         self.UsePopUp(True)
-        self.SetSelBackground(True, "#FFFF00")
         self.SetUseHorizontalScrollBar(True)
 
+        # support light and dark mode
+        bg_color = wx.SystemSettings().GetColour(wx.SYS_COLOUR_WINDOW)
+        fg_color = wx.SystemSettings().GetColour(wx.SYS_COLOUR_WINDOWTEXT)
+        selection_color = wx.SystemSettings().GetColour(wx.SYS_COLOUR_HIGHLIGHT)
+        self.StyleSetBackground(wx.stc.STC_STYLE_DEFAULT, bg_color)
+        self.StyleSetForeground(wx.stc.STC_STYLE_DEFAULT, fg_color)
+        self.SetCaretForeground(fg_color)
+        self.SetSelBackground(True, selection_color)
+        self.StyleClearAll()
+
         #
         # bindings
         #