Skip to content

Commit

Permalink
Editor: Workaround to correctly set background color on Mac
Browse files Browse the repository at this point in the history
Fixes #2028
  • Loading branch information
ccordoba12 committed Jun 20, 2015
1 parent 568d715 commit fa77637
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions spyderlib/widgets/sourcecode/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
13 changes: 13 additions & 0 deletions spyderlib/widgets/sourcecode/codeeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit fa77637

Please sign in to comment.