From fa77637787b8da10f9415494d7b13647ac335945 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Sat, 20 Jun 2015 14:11:18 -0500 Subject: [PATCH] Editor: Workaround to correctly set background color on Mac Fixes #2028 --- spyderlib/widgets/sourcecode/base.py | 9 +++++++++ spyderlib/widgets/sourcecode/codeeditor.py | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/spyderlib/widgets/sourcecode/base.py b/spyderlib/widgets/sourcecode/base.py index 4112ac2117a..7aac23a7736 100644 --- a/spyderlib/widgets/sourcecode/base.py +++ b/spyderlib/widgets/sourcecode/base.py @@ -242,6 +242,15 @@ def set_palette(self, background, foreground): palette.setColor(QPalette.Text, foreground) self.setPalette(palette) + # Set the right background color when changing color schemes + # or creating new Editor windows. This seems to be a Qt bug. + # Fixes Issue 2028 + if sys.platform == 'darwin': + if self.objectName(): + style = "QPlainTextEdit#%s {background: %s;}" % \ + (self.objectName(), background.name()) + self.setStyleSheet(style) + #------Extra selections def get_extra_selections(self, key): diff --git a/spyderlib/widgets/sourcecode/codeeditor.py b/spyderlib/widgets/sourcecode/codeeditor.py index 571fcef610c..07597352560 100644 --- a/spyderlib/widgets/sourcecode/codeeditor.py +++ b/spyderlib/widgets/sourcecode/codeeditor.py @@ -356,6 +356,19 @@ def __init__(self, parent=None): TextEditBaseWidget.__init__(self, parent) self.setFocusPolicy(Qt.StrongFocus) + # We use these object names to set the right background + # color when changing color schemes or creating new + # Editor windows. This seems to be a Qt bug. + # Fixes Issue 2028 + if sys.platform == 'darwin': + plugin_name = repr(parent) + if 'editor' in plugin_name.lower(): + self.setObjectName('editor') + elif 'inspector' in plugin_name.lower(): + self.setObjectName('inspector') + elif 'historylog' in plugin_name.lower(): + self.setObjectName('historylog') + # Completion completion_size = CONF.get('editor_appearance', 'completion/size') completion_font = get_font('editor')