diff --git a/config.py b/config.py index 90744a329..4102679da 100644 --- a/config.py +++ b/config.py @@ -58,31 +58,21 @@ CATALOG = 'lang' -isDark = False -try: - isDark = wx.SystemAppearance().IsDark() -except (KeyboardInterrupt, SystemExit): - raise -except: - pass - - -if isDark: - slotColourMap = { - FittingSlot.LOW: wx.Colour(44, 36, 19), # yellow = low slots 24/13 - FittingSlot.MED: wx.Colour(28, 39, 51), # blue = mid slots 8.1/9.5 - FittingSlot.HIGH: wx.Colour(53, 31, 34), # red = high slots 6.5/11.5 - FittingSlot.RIG: '', - FittingSlot.SUBSYSTEM: ''} - errColor = wx.Colour(70, 20, 20) -else: - slotColourMap = { - FittingSlot.LOW: wx.Colour(250, 235, 204), # yellow = low slots - FittingSlot.MED: wx.Colour(188, 215, 241), # blue = mid slots - FittingSlot.HIGH: wx.Colour(235, 204, 209), # red = high slots - FittingSlot.RIG: '', - FittingSlot.SUBSYSTEM: ''} - errColor = wx.Colour(204, 51, 51) + +slotColourMapDark = { + FittingSlot.LOW: wx.Colour(44, 36, 19), # yellow = low slots 24/13 + FittingSlot.MED: wx.Colour(28, 39, 51), # blue = mid slots 8.1/9.5 + FittingSlot.HIGH: wx.Colour(53, 31, 34), # red = high slots 6.5/11.5 + FittingSlot.RIG: '', + FittingSlot.SUBSYSTEM: ''} +errColorDark = wx.Colour(70, 20, 20) +slotColourMap = { + FittingSlot.LOW: wx.Colour(250, 235, 204), # yellow = low slots + FittingSlot.MED: wx.Colour(188, 215, 241), # blue = mid slots + FittingSlot.HIGH: wx.Colour(235, 204, 209), # red = high slots + FittingSlot.RIG: '', + FittingSlot.SUBSYSTEM: ''} +errColor = wx.Colour(204, 51, 51) def getClientSecret(): diff --git a/gui/builtinItemStatsViews/helpers.py b/gui/builtinItemStatsViews/helpers.py index 5a863365a..e6069c526 100644 --- a/gui/builtinItemStatsViews/helpers.py +++ b/gui/builtinItemStatsViews/helpers.py @@ -4,13 +4,15 @@ # noinspection PyPackageRequirements import wx.lib.mixins.listctrl as listmix +from gui.utils.dark import isDark + class AutoListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ListRowHighlighter): def __init__(self, parent, ID, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0): wx.ListCtrl.__init__(self, parent, ID, pos, size, style) listmix.ListCtrlAutoWidthMixin.__init__(self) listmix.ListRowHighlighter.__init__(self) - if wx.SystemSettings.GetAppearance().IsDark(): + if isDark(): listcol = wx.SystemSettings.GetColour(wx.SYS_COLOUR_LISTBOX) highlight = listcol.ChangeLightness(110) listmix.ListRowHighlighter.SetHighlightColor(self, highlight) diff --git a/gui/builtinViews/fittingView.py b/gui/builtinViews/fittingView.py index 996992908..e9f75e109 100644 --- a/gui/builtinViews/fittingView.py +++ b/gui/builtinViews/fittingView.py @@ -39,9 +39,10 @@ from gui.chrome_tabs import EVT_NOTEBOOK_PAGE_CHANGED from gui.contextMenu import ContextMenu from gui.utils.staticHelpers import DragDropHelper +from gui.utils.dark import isDark from service.fit import Fit from service.market import Market -from config import slotColourMap, errColor +from config import slotColourMap, slotColourMapDark, errColor, errColorDark from gui.fitCommands.helpers import getSimilarModPositions pyfalog = Logger(__name__) @@ -729,7 +730,10 @@ def click(self, event): event.Skip() def slotColour(self, slot): - return slotColourMap.get(slot) or self.GetBackgroundColour() + if isDark(): + return slotColourMapDark.get(slot) or self.GetBackgroundColour() + else: + return slotColourMap.get(slot) or self.GetBackgroundColour() def refresh(self, stuff): """ @@ -774,7 +778,7 @@ def refresh(self, stuff): if slotMap[mod.slot] or hasRestrictionOverriden: # Color too many modules as red - self.SetItemBackgroundColour(i, errColor) + self.SetItemBackgroundColour(i, errColorDark if isDark() else errColor) elif sFit.serviceFittingOptions["colorFitBySlot"]: # Color by slot it enabled self.SetItemBackgroundColour(i, self.slotColour(mod.slot)) diff --git a/gui/utils/dark.py b/gui/utils/dark.py new file mode 100644 index 000000000..ca0ace86e --- /dev/null +++ b/gui/utils/dark.py @@ -0,0 +1,10 @@ +import wx + + +def isDark(): + try: + return wx.SystemSettings.GetAppearance().IsDark() + except (KeyboardInterrupt, SystemExit): + raise + except: + return False