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 3 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
43 changes: 38 additions & 5 deletions spyder/app/tour.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,38 @@

# 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.py3compat import to_binary_string
from spyder.utils.qthelpers import add_actions, create_action
from spyder.utils import icon_manager as ima


def get_colors():
ccordoba12 marked this conversation as resolved.
Show resolved Hide resolved
"""
Get top and background colors for the tour 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')
ccordoba12 marked this conversation as resolved.
Show resolved Hide resolved
if ui_theme == 'dark':
top_color = QColor.fromRgb(35, 38, 41)
back_color = QColor.fromRgb(35, 38, 41)
ccordoba12 marked this conversation as resolved.
Show resolved Hide resolved
elif ui_theme == 'automatic':
if not is_dark_font_color(color_scheme):
top_color = QColor.fromRgb(35, 38, 41)
back_color = QColor.fromRgb(35, 38, 41)
ccordoba12 marked this conversation as resolved.
Show resolved Hide resolved
else:
top_color = QColor.fromRgb(230, 230, 230)
back_color = QColor.fromRgb(255, 255, 255)
ccordoba12 marked this conversation as resolved.
Show resolved Hide resolved
else:
top_color = QColor.fromRgb(230, 230, 230)
back_color = QColor.fromRgb(255, 255, 255)
ccordoba12 marked this conversation as resolved.
Show resolved Hide resolved
return top_color, back_color


MAIN_TOP_COLOR, MAIN_BG_COLOR = get_colors()

# 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 +555,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,9 +611,13 @@ def toolbutton(icon):

arrow = get_image_path('hide.png')

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:
''' + self.combobox_background.name() + '''
ccordoba12 marked this conversation as resolved.
Show resolved Hide resolved
border-width: 0px;
border-radius: 0px;
min-height:20px;
Expand Down Expand Up @@ -869,7 +900,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
27 changes: 26 additions & 1 deletion spyder/plugins/plots/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,36 @@

# Local imports
from spyder.config.base import _
from spyder.config.main import CONF
from spyder.config.gui import is_dark_font_color
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


def get_background_color():
"""
Get background color for the plots plugin 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')
ccordoba12 marked this conversation as resolved.
Show resolved Hide resolved
if ui_theme == 'dark':
background_color = '#232629'
elif ui_theme == 'automatic':
if not is_dark_font_color(color_scheme):
background_color = '#232629'
else:
background_color = 'white'
else:
background_color = 'white'
return background_color


MAIN_BG_COLOR = get_background_color()


class PlotsConfigPage(PluginConfigPage):

def setup_page(self):
Expand Down Expand Up @@ -89,7 +113,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
10 changes: 6 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,10 @@ 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: " + background_color)
self.setFrameStyle(0)

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

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


def get_text_color():
"""
Get text color for the profiler plugin 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')
ccordoba12 marked this conversation as resolved.
Show resolved Hide resolved
if ui_theme == 'dark':
text_color = 'white'
elif ui_theme == 'automatic':
if not is_dark_font_color(color_scheme):
text_color = 'white'
else:
text_color = '#444444'
else:
text_color = '#444444'
return text_color


MAIN_TEXT_COLOR = get_text_color()


class ProfilerConfigPage(PluginConfigPage):
def setup_page(self):
results_group = QGroupBox(_("Results"))
Expand Down Expand Up @@ -65,7 +89,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
32 changes: 31 additions & 1 deletion spyder/plugins/pylint/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

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


def get_colors():
"""
Get text and previous rate color for the pylint plugin 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')
ccordoba12 marked this conversation as resolved.
Show resolved Hide resolved
if ui_theme == 'dark':
text_color = 'white'
prevrate_color = 'white'
elif ui_theme == 'automatic':
if not is_dark_font_color(color_scheme):
text_color = 'white'
prevrate_color = 'white'
else:
text_color = '#444444'
prevrate_color = '#666666'
else:
text_color = '#444444'
prevrate_color = '#666666'
return text_color, prevrate_color


MAIN_TEXT_COLOR, MAIN_PREVRATE_COLOR = get_colors()


class PylintConfigPage(PluginConfigPage):
def setup_page(self):
settings_group = QGroupBox(_("Settings"))
Expand Down Expand Up @@ -90,7 +118,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