Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Missing dark style for QMenus, Tour, Pylint, Profiler and DataFrameEditor #8201

Merged
merged 5 commits into from
Nov 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions spyder/app/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ def create_edit_action(text, tr_text, icon):

#----- Tours
self.tour = tour.AnimatedTour(self)
self.tours_menu = QMenu(_("Interactive tours"))
self.tours_menu = QMenu(_("Interactive tours"), self)
self.tour_menu_actions = []
# TODO: Only show intro tour for now. When we are close to finish
# 3.0, we will finish and show the other tour
Expand Down Expand Up @@ -1097,7 +1097,7 @@ def add_ipm_action(text, path):
add_actions(pymods_menu, ipm_actions)
self.help_menu_actions.append(pymods_menu)
# Online documentation
web_resources = QMenu(_("Online documentation"))
web_resources = QMenu(_("Online documentation"), self)
webres_actions = create_module_bookmark_actions(self,
self.BOOKMARKS)
webres_actions.insert(2, None)
Expand Down
38 changes: 25 additions & 13 deletions spyder/app/tour.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,18 @@

# Local imports
from spyder.config.base import _, get_image_path
from spyder.config.gui import is_dark_interface
from spyder.py3compat import to_binary_string
from spyder.utils.qthelpers import add_actions, create_action
from spyder.utils import icon_manager as ima


if is_dark_interface():
MAIN_TOP_COLOR = MAIN_BG_COLOR = QColor.fromRgb(35, 38, 41)
else:
MAIN_TOP_COLOR = QColor.fromRgb(230, 230, 230)
MAIN_BG_COLOR = QColor.fromRgb(255, 255, 255)

# FIXME: Known issues
# How to handle if an specific dockwidget does not exists/load, like ipython
# on python3.3, should that frame be removed? should it display a warning?
Expand Down Expand Up @@ -527,16 +535,15 @@ def focusOutEvent(self, event):

class FadingTipBox(FadingDialog):
""" """
def __init__(self, parent, opacity, duration, easing_curve, tour=None):
def __init__(self, parent, opacity, duration, easing_curve, tour=None,
color_top=None, color_back=None, combobox_background=None):
super(FadingTipBox, self).__init__(parent, opacity, duration,
easing_curve)
self.holder = self.anim # needed for qt to work
self.parent = parent
self.tour = tour

self.frames = None
self.color_top = QColor.fromRgb(230, 230, 230)
self.color_back = QColor.fromRgb(255, 255, 255)
self.offset_shadow = 0
self.fixed_width = 300

Expand Down Expand Up @@ -584,26 +591,29 @@ def toolbutton(icon):

arrow = get_image_path('hide.png')

self.stylesheet = '''QComboBox {
self.color_top = color_top
self.color_back = color_back
self.combobox_background = combobox_background
self.stylesheet = '''QComboBox {{
padding-left: 5px;
background-color: rgbs(230,230,230,100%);
background-color: {}
border-width: 0px;
border-radius: 0px;
min-height:20px;
max-height:20px;
}
}}

QComboBox::drop-down {
QComboBox::drop-down {{
subcontrol-origin: padding;
subcontrol-position: top left;
border-width: 0px;
}
}}

QComboBox::down-arrow {
image: url(''' + arrow + ''');
}
QComboBox::down-arrow {{
image: url({});
}}

'''
'''.format(self.combobox_background.name(), arrow)
# Windows fix, slashes should be always in unix-style
self.stylesheet = self.stylesheet.replace('\\', '/')

Expand Down Expand Up @@ -869,7 +879,9 @@ def __init__(self, parent):
self.color, tour=self)
self.tips = FadingTipBox(self.parent, self.opacity_tips,
self.duration_tips, self.easing_curve,
tour=self)
tour=self, color_top=MAIN_TOP_COLOR,
color_back=MAIN_BG_COLOR,
combobox_background=MAIN_TOP_COLOR)

# Widgets setup
# Needed to fix issue #2204
Expand Down
14 changes: 14 additions & 0 deletions spyder/config/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,19 @@ def is_dark_font_color(color_scheme):
return dark_color(font_color)


def is_dark_interface():
ui_theme = CONF.get('color_schemes', 'ui_theme')
color_scheme = CONF.get('color_schemes', 'selected')
if ui_theme == 'dark':
return True
elif ui_theme == 'automatic':
if not is_dark_font_color(color_scheme):
return True
else:
return False
else:
return False


for _name in sh.COLOR_SCHEME_NAMES:
set_default_color_scheme(_name, replace=False)
10 changes: 9 additions & 1 deletion spyder/plugins/plots/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@

# Local imports
from spyder.config.base import _
from spyder.config.gui import is_dark_interface
from spyder.api.plugins import SpyderPluginWidget
from spyder.api.preferences import PluginConfigPage
from spyder.utils import icon_manager as ima
from spyder.plugins.plots.widgets.figurebrowser import FigureBrowser


if is_dark_interface():
MAIN_BG_COLOR = '#232629'
else:
MAIN_BG_COLOR = 'white'


class PlotsConfigPage(PluginConfigPage):

def setup_page(self):
Expand Down Expand Up @@ -89,7 +96,8 @@ def add_shellwidget(self, shellwidget):
if shellwidget_id not in self.shellwidgets:
self.options_button.setVisible(True)
fig_browser = FigureBrowser(
self, options_button=self.options_button)
self, options_button=self.options_button,
background_color=MAIN_BG_COLOR)
fig_browser.set_shellwidget(shellwidget)
fig_browser.setup(**self.get_settings())
fig_browser.sig_option_changed.connect(
Expand Down
11 changes: 7 additions & 4 deletions spyder/plugins/plots/widgets/figurebrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ class FigureBrowser(QWidget):
sig_option_changed = Signal(str, object)
sig_collapse = Signal()

def __init__(self, parent, options_button=None, plugin_actions=[]):
def __init__(self, parent, options_button=None, plugin_actions=[],
background_color=None):
super(FigureBrowser, self).__init__(parent)

self.shellwidget = None
self.is_visible = True
self.figviewer = None
self.setup_in_progress = False
self.background_color = background_color

# Options :
self.mute_inline_plotting = None
Expand All @@ -101,7 +103,7 @@ def setup(self, mute_inline_plotting=None, show_plot_outline=None):
self.show_plot_outline_action.setChecked(show_plot_outline)
return

self.figviewer = FigureViewer()
self.figviewer = FigureViewer(background_color=self.background_color)
self.figviewer.setStyleSheet("FigureViewer{"
"border: 1px solid lightgrey;"
"border-top-width: 0px;"
Expand Down Expand Up @@ -311,10 +313,11 @@ class FigureViewer(QScrollArea):

sig_zoom_changed = Signal(float)

def __init__(self, parent=None):
def __init__(self, parent=None, background_color=None):
super(FigureViewer, self).__init__(parent)
self.setAlignment(Qt.AlignCenter)
self.viewport().setStyleSheet("background-color: white")
self.viewport().setStyleSheet(
"background-color: {}".format(background_color))
self.setFrameStyle(0)

self._scalefactor = 0
Expand Down
10 changes: 9 additions & 1 deletion spyder/plugins/profiler/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

# Local imports
from spyder.config.base import _
from spyder.config.gui import is_dark_interface
from spyder.api.plugins import SpyderPluginWidget
from spyder.api.preferences import PluginConfigPage
from spyder.preferences.runconfig import get_run_configuration
Expand All @@ -27,6 +28,12 @@
from .widgets.profilergui import (ProfilerWidget, is_profiler_installed)


if is_dark_interface():
MAIN_TEXT_COLOR = 'white'
else:
MAIN_TEXT_COLOR = '#444444'


class ProfilerConfigPage(PluginConfigPage):
def setup_page(self):
results_group = QGroupBox(_("Results"))
Expand Down Expand Up @@ -65,7 +72,8 @@ def __init__(self, parent=None):

max_entries = self.get_option('max_entries', 50)
self.profiler = ProfilerWidget(self, max_entries,
options_button=self.options_button)
options_button=self.options_button,
text_color=MAIN_TEXT_COLOR)

layout = QVBoxLayout()
layout.addWidget(self.profiler)
Expand Down
14 changes: 9 additions & 5 deletions spyder/plugins/profiler/widgets/profilergui.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,17 @@ class ProfilerWidget(QWidget):
VERSION = '0.0.1'
redirect_stdio = Signal(bool)

def __init__(self, parent, max_entries=100, options_button=None):
def __init__(self, parent, max_entries=100, options_button=None,
text_color=None):
QWidget.__init__(self, parent)

self.setWindowTitle("Profiler")

self.output = None
self.error_output = None


self.text_color = text_color

self._last_wdir = None
self._last_args = None
self._last_pythonpath = None
Expand Down Expand Up @@ -365,9 +368,10 @@ def show_data(self, justanalyzed=False):
self.datatree.load_data(self.DATAPATH)
self.datatree.show_tree()

text_style = "<span style=\'color: #444444\'><b>%s </b></span>"
date_text = text_style % time.strftime("%Y-%m-%d %H:%M:%S",
time.localtime())
text_style = "<span style=\'color: %s\'><b>%s </b></span>"
date_text = text_style % (self.text_color,
time.strftime("%Y-%m-%d %H:%M:%S",
time.localtime()))
self.datelabel.setText(date_text)


Expand Down
13 changes: 12 additions & 1 deletion spyder/plugins/pylint/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

# Local imports
from spyder.config.base import _
from spyder.config.gui import is_dark_interface
from spyder.api.plugins import SpyderPluginWidget
from spyder.api.preferences import PluginConfigPage
from spyder.utils import icon_manager as ima
Expand All @@ -31,6 +32,14 @@
from .widgets.pylintgui import PylintWidget


if is_dark_interface():
MAIN_TEXT_COLOR = 'white'
MAIN_PREVRATE_COLOR = 'white'
else:
MAIN_TEXT_COLOR = '#444444'
MAIN_PREVRATE_COLOR = '#666666'


class PylintConfigPage(PluginConfigPage):
def setup_page(self):
settings_group = QGroupBox(_("Settings"))
Expand Down Expand Up @@ -90,7 +99,9 @@ def __init__(self, parent=None):

max_entries = self.get_option('max_entries', 50)
self.pylint = PylintWidget(self, max_entries=max_entries,
options_button=self.options_button)
options_button=self.options_button,
text_color=MAIN_TEXT_COLOR,
prevrate_color=MAIN_PREVRATE_COLOR)

layout = QVBoxLayout()
layout.addWidget(self.pylint)
Expand Down
20 changes: 12 additions & 8 deletions spyder/plugins/pylint/widgets/pylintgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,18 @@ class PylintWidget(QWidget):
VERSION = '1.1.0'
redirect_stdio = Signal(bool)

def __init__(self, parent, max_entries=100, options_button=None):
def __init__(self, parent, max_entries=100, options_button=None,
text_color=None, prevrate_color=None):
QWidget.__init__(self, parent)

self.setWindowTitle("Pylint")

self.output = None
self.error_output = None


self.text_color = text_color
self.prevrate_color = prevrate_color

self.max_entries = max_entries
self.rdata = []
if osp.isfile(self.DATAPATH):
Expand Down Expand Up @@ -432,26 +436,26 @@ def show_data(self, justanalyzed=False):
self.treewidget.clear_results()
date_text = ''
else:
text_style = "<span style=\'color: #444444\'><b>%s </b></span>"
text_style = "<span style=\'color: %s\'><b>%s </b></span>"
rate_style = "<span style=\'color: %s\'><b>%s</b></span>"
prevrate_style = "<span style=\'color: #666666\'>%s</span>"
prevrate_style = "<span style=\'color: %s\'>%s</span>"
color = "#FF0000"
if float(rate) > 5.:
color = "#22AA22"
elif float(rate) > 3.:
color = "#EE5500"
text = _('Global evaluation:')
text = (text_style % text)+(rate_style % (color,
('%s/10' % rate)))
text = ((text_style % (self.text_color, text))
+ (rate_style % (color, ('%s/10' % rate))))
if previous_rate:
text_prun = _('previous run:')
text_prun = ' (%s %s/10)' % (text_prun, previous_rate)
text += prevrate_style % text_prun
text += prevrate_style % (self.prevrate_color, text_prun)
self.treewidget.set_results(filename, results)
date = to_text_string(time.strftime("%Y-%m-%d %H:%M:%S",
datetime),
encoding='utf8')
date_text = text_style % date
date_text = text_style % (self.text_color, date)

self.ratelabel.setText(text)
self.datelabel.setText(date_text)
Expand Down
4 changes: 0 additions & 4 deletions spyder/plugins/variableexplorer/widgets/dataframeeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,10 +705,6 @@ def data(self, index, role):
return None
row, col = ((index.row(), index.column()) if self.axis == 0
else (index.column(), index.row()))
if role == Qt.BackgroundRole:
prev = self.model.header(self.axis, col - 1, row) if col else None
cur = self.model.header(self.axis, col, row)
return self._palette.midlight() if prev != cur else None
if role != Qt.DisplayRole:
return None
if self.axis == 0 and self._shape[0] <= 1:
Expand Down
25 changes: 5 additions & 20 deletions spyder/utils/icon_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,15 @@
# Local imports
from spyder.config.base import get_image_path
from spyder.config.main import CONF
from spyder.config.gui import is_dark_font_color
from spyder.config.gui import is_dark_interface
import qtawesome as qta


def get_foreground_color():
"""
Get main color for the icons based on the color theme
and color scheme currently selected.
"""
ui_theme = CONF.get('color_schemes', 'ui_theme')
color_scheme = CONF.get('color_schemes', 'selected')
if ui_theme == 'dark':
foreground_color = 'white'
elif ui_theme == 'automatic':
if not is_dark_font_color(color_scheme):
foreground_color = 'white'
else:
foreground_color = 'black'
else:
foreground_color = 'black'
return foreground_color

if is_dark_interface():
MAIN_FG_COLOR = 'white'
else:
MAIN_FG_COLOR = 'black'

MAIN_FG_COLOR = get_foreground_color()

_resource = {
'directory': osp.join(osp.dirname(osp.realpath(__file__)), '../fonts'),
Expand Down