Skip to content

Commit 2f3b60d

Browse files
committed
feat(theme): style input controls and lists
Apply Colors.styleInput() to TextCtrl, Choice, ComboBox controls. On Windows, native controls ignore SetBackgroundColour due to visual styles. styleInput() calls SetWindowTheme() via ctypes to disable native theming, allowing custom dark backgrounds to render correctly. Apply theme colors to MarketTree, preference views, ESI fittings.
1 parent c3c05e5 commit 2f3b60d

File tree

10 files changed

+32
-7
lines changed

10 files changed

+32
-7
lines changed

gui/builtinMarketBrowser/marketTree.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from gui.cachingImageList import CachingImageList
44
from gui.builtinMarketBrowser.events import RECENTLY_USED_MODULES, CHARGES_FOR_FIT
5+
from gui.utils.colors import Colors
56

67
from logbook import Logger
78

@@ -13,6 +14,8 @@ class MarketTree(wx.TreeCtrl):
1314

1415
def __init__(self, parent, marketBrowser):
1516
wx.TreeCtrl.__init__(self, parent, style=wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT)
17+
self.SetBackgroundColour(Colors.listBackground())
18+
self.SetForegroundColour(Colors.text())
1619
pyfalog.debug("Initialize marketTree")
1720
self.root = self.AddRoot("root")
1821

gui/builtinMarketBrowser/pfSearchBox.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import wx
33
import gui.utils.color as colorUtils
44
import gui.utils.draw as drawUtils
5+
from gui.utils.colors import Colors
56
from gui.utils.helpers_wxPython import HandleCtrlBackspace
67

78
SearchButton, EVT_SEARCH_BTN = wx.lib.newevent.NewEvent()
@@ -44,6 +45,7 @@ def __init__(self, parent, id=wx.ID_ANY, value="", pos=wx.DefaultPosition, size=
4445
self.EditBox = wx.TextCtrl(self, wx.ID_ANY, "", wx.DefaultPosition,
4546
(-1, h - 2 if 'wxGTK' in wx.PlatformInfo else -1),
4647
wx.TE_PROCESS_ENTER | (wx.BORDER_NONE if 'wxGTK' in wx.PlatformInfo else 0))
48+
Colors.styleInput(self.EditBox)
4749

4850
self.Bind(wx.EVT_PAINT, self.OnPaint)
4951
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBk)
@@ -235,7 +237,7 @@ def UpdateElementsPos(self, dc):
235237
def OnPaint(self, event):
236238
dc = wx.AutoBufferedPaintDC(self)
237239

238-
bkColor = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW)
240+
bkColor = Colors.windowBackground()
239241
sepColor = colorUtils.GetSuitable(bkColor, 0.2)
240242
rect = self.GetRect()
241243

gui/builtinPreferenceViews/pyfaDatabasePreferences.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from gui.bitmap_loader import BitmapLoader
66
from gui.preferenceView import PreferenceView
77
from gui.utils import helpers_wxPython as wxHelpers
8+
from gui.utils.colors import Colors
89

910
_t = wx.GetTranslation
1011

@@ -40,7 +41,7 @@ def populatePanel(self, panel):
4041
mainSizer.Add(self.stSetUserPath, 0, wx.ALL, 5)
4142
self.inputUserPath = wx.TextCtrl(panel, wx.ID_ANY, config.savePath, wx.DefaultPosition, wx.DefaultSize, 0)
4243
self.inputUserPath.SetEditable(False)
43-
self.inputUserPath.SetBackgroundColour((200, 200, 200))
44+
Colors.styleInput(self.inputUserPath, disabled=True)
4445
mainSizer.Add(self.inputUserPath, 0, wx.ALL | wx.EXPAND, 5)
4546

4647
# Save DB
@@ -50,7 +51,7 @@ def populatePanel(self, panel):
5051

5152
self.inputFitDB = wx.TextCtrl(panel, wx.ID_ANY, config.saveDB, wx.DefaultPosition, wx.DefaultSize, 0)
5253
self.inputFitDB.SetEditable(False)
53-
self.inputFitDB.SetBackgroundColour((200, 200, 200))
54+
Colors.styleInput(self.inputFitDB, disabled=True)
5455
mainSizer.Add(self.inputFitDB, 0, wx.ALL | wx.EXPAND, 5)
5556

5657
# Game Data DB
@@ -60,7 +61,7 @@ def populatePanel(self, panel):
6061

6162
self.inputGameDB = wx.TextCtrl(panel, wx.ID_ANY, config.gameDB, wx.DefaultPosition, wx.DefaultSize, 0)
6263
self.inputGameDB.SetEditable(False)
63-
self.inputGameDB.SetBackgroundColour((200, 200, 200))
64+
Colors.styleInput(self.inputGameDB, disabled=True)
6465
mainSizer.Add(self.inputGameDB, 0, wx.ALL | wx.EXPAND, 5)
6566

6667
self.cbsaveInRoot.SetValue(config.saveInRoot)

gui/builtinPreferenceViews/pyfaEsiPreferences.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import gui.mainFrame
66
from gui.bitmap_loader import BitmapLoader
77
from gui.preferenceView import PreferenceView
8+
from gui.utils.colors import Colors
89
from service.esi import Esi
910
from service.settings import EsiSettings
1011

@@ -67,6 +68,7 @@ def populatePanel(self, panel):
6768
self.esiServer.SetToolTip(wx.ToolTip(_t('The source you choose will be used on connection.')))
6869

6970
self.chESIserver = wx.Choice(panel, choices=list(self.settings.keys()))
71+
Colors.styleInput(self.chESIserver)
7072

7173
self.chESIserver.SetStringSelection(self.settings.get("server"))
7274

gui/builtinPreferenceViews/pyfaLoggingPreferences.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from gui.preferenceView import PreferenceView
44
from gui.bitmap_loader import BitmapLoader
5+
from gui.utils.colors import Colors
56
import config
67
from logbook import Logger
78

@@ -40,7 +41,7 @@ def populatePanel(self, panel):
4041
mainSizer.Add(self.stLogPath, 0, wx.ALL, 5)
4142
self.inputLogPath = wx.TextCtrl(panel, wx.ID_ANY, config.logPath, wx.DefaultPosition, wx.DefaultSize, 0)
4243
self.inputLogPath.SetEditable(False)
43-
self.inputLogPath.SetBackgroundColour((200, 200, 200))
44+
Colors.styleInput(self.inputLogPath, disabled=True)
4445
mainSizer.Add(self.inputLogPath, 0, wx.ALL | wx.EXPAND, 5)
4546

4647
import requests
@@ -49,7 +50,7 @@ def populatePanel(self, panel):
4950
mainSizer.Add(self.certPath, 0, wx.ALL, 5)
5051
self.certPathCtrl = wx.TextCtrl(panel, wx.ID_ANY, requests.certs.where(), wx.DefaultPosition, wx.DefaultSize, 0)
5152
self.certPathCtrl.SetEditable(False)
52-
self.certPathCtrl.SetBackgroundColour((200, 200, 200))
53+
Colors.styleInput(self.certPathCtrl, disabled=True)
5354
mainSizer.Add(self.certPathCtrl, 0, wx.ALL | wx.EXPAND, 5)
5455

5556
# Debug Logging

gui/builtinPreferenceViews/pyfaMarketPreferences.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from gui.preferenceView import PreferenceView
66
from gui.bitmap_loader import BitmapLoader
7+
from gui.utils.colors import Colors
78

89
import gui.mainFrame
910
import gui.globalEvents as GE
@@ -44,6 +45,7 @@ def populatePanel(self, panel):
4445
_t('The delay between a keystroke and the market search. Can help reduce lag when typing fast in the market search box.')))
4546
delayTimer.Add(self.stMarketDelay, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
4647
self.intDelay = IntCtrl(panel, max=1000, limited=True)
48+
Colors.styleInput(self.intDelay)
4749
delayTimer.Add(self.intDelay, 0, wx.ALL, 5)
4850
mainSizer.Add(delayTimer, 0, wx.EXPAND | wx.TOP | wx.RIGHT, 10)
4951
self.intDelay.SetValue(self.sFit.serviceFittingOptions["marketSearchDelay"])
@@ -65,6 +67,8 @@ def populatePanel(self, panel):
6567
'The system you choose will also be tried first, and if no data is available, global price will be used.')))
6668
self.chPriceSource = wx.Choice(panel, choices=sorted(Price.sources.keys()))
6769
self.chPriceSystem = wx.Choice(panel, choices=list(Price.systemsList.keys()))
70+
Colors.styleInput(self.chPriceSource)
71+
Colors.styleInput(self.chPriceSystem)
6872
priceSizer.Add(self.chPriceSource, 1, wx.ALL | wx.EXPAND, 5)
6973
priceSizer.Add(self.chPriceSystem, 1, wx.ALL | wx.EXPAND, 5)
7074
mainSizer.Add(priceSizer, 0, wx.EXPAND | wx.TOP | wx.RIGHT, 10)

gui/builtinPreferenceViews/pyfaNetworkPreferences.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from gui.preferenceView import PreferenceView
55
from gui.bitmap_loader import BitmapLoader
6+
from gui.utils.colors import Colors
67

78
import gui.mainFrame
89
from service.settings import NetworkSettings
@@ -86,6 +87,7 @@ def populatePanel(self, panel):
8687

8788
self.chProxyTypeChoices = [_t("No proxy"), _t("Auto-detected proxy settings"), _t("Manual proxy settings")]
8889
self.chProxyType = wx.Choice(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, self.chProxyTypeChoices, 0)
90+
Colors.styleInput(self.chProxyType)
8991

9092
self.chProxyType.SetSelection(self.nMode)
9193

@@ -103,6 +105,7 @@ def populatePanel(self, panel):
103105
fgAddrSizer.Add(self.stPSetAddr, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
104106

105107
self.editProxySettingsAddr = wx.TextCtrl(panel, wx.ID_ANY, self.nAddr, wx.DefaultPosition, wx.DefaultSize, 0)
108+
Colors.styleInput(self.editProxySettingsAddr)
106109

107110
fgAddrSizer.Add(self.editProxySettingsAddr, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5)
108111

@@ -112,6 +115,7 @@ def populatePanel(self, panel):
112115
fgAddrSizer.Add(self.stPSetPort, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
113116

114117
self.editProxySettingsPort = wx.TextCtrl(panel, wx.ID_ANY, self.nPort, wx.DefaultPosition, wx.DefaultSize, 0)
118+
Colors.styleInput(self.editProxySettingsPort)
115119

116120
fgAddrSizer.Add(self.editProxySettingsPort, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5)
117121

@@ -122,10 +126,12 @@ def populatePanel(self, panel):
122126
self.stPSetLogin.Wrap(-1)
123127
self.editProxySettingsLogin = wx.TextCtrl(panel, wx.ID_ANY, self.nAuth[0], wx.DefaultPosition, wx.DefaultSize,
124128
0)
129+
Colors.styleInput(self.editProxySettingsLogin)
125130
self.stPSetPassword = wx.StaticText(panel, wx.ID_ANY, _t("Password:"), wx.DefaultPosition, wx.DefaultSize, 0)
126131
self.stPSetPassword.Wrap(-1)
127132
self.editProxySettingsPassword = wx.TextCtrl(panel, wx.ID_ANY, self.nAuth[1], wx.DefaultPosition,
128133
wx.DefaultSize, wx.TE_PASSWORD)
134+
Colors.styleInput(self.editProxySettingsPassword)
129135
pAuthSizer = wx.BoxSizer(wx.HORIZONTAL)
130136
pAuthSizer.Add(self.stPSetLogin, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
131137
pAuthSizer.Add(self.editProxySettingsLogin, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)

gui/builtinViews/entityEditor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# noinspection PyPackageRequirements
22
import wx
33
from gui.bitmap_loader import BitmapLoader
4+
from gui.utils.colors import Colors
45

56

67
class BaseValidator(wx.Validator):
@@ -45,6 +46,7 @@ def __init__(self, parent, entityName, selected=None):
4546
self.choices = []
4647
self.choices.sort(key=lambda p: p.name)
4748
self.entityChoices = wx.Choice(self, choices=[p.name for p in self.choices])
49+
Colors.styleInput(self.entityChoices)
4850
self.navSizer.Add(self.entityChoices, 1, wx.ALL, 5)
4951

5052
buttons = (("new", wx.ART_NEW, self.OnNew),

gui/esiFittings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from service.port import Port
2121
from service.port.esi import ESIExportException
2222
from service.settings import EsiSettings
23+
from gui.utils.colors import Colors
2324

2425

2526
_t = wx.GetTranslation
@@ -39,6 +40,7 @@ def __init__(self, parent):
3940
characterSelectSizer = wx.BoxSizer(wx.HORIZONTAL)
4041

4142
self.charChoice = wx.Choice(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, [])
43+
Colors.styleInput(self.charChoice)
4244
characterSelectSizer.Add(self.charChoice, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
4345
self.updateCharList()
4446

@@ -276,6 +278,7 @@ def __init__(self, parent):
276278
hSizer = wx.BoxSizer(wx.HORIZONTAL)
277279

278280
self.charChoice = wx.Choice(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, [])
281+
Colors.styleInput(self.charChoice)
279282
hSizer.Add(self.charChoice, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
280283
self.updateCharList()
281284
self.charChoice.SetSelection(0)

gui/utils/inputs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import wx
2525

2626
from eos.utils.float import floatUnerr
27+
from gui.utils.colors import Colors
2728

2829

2930
def valToStr(val):
@@ -77,7 +78,7 @@ def ChangeValueFloat(self, value):
7778

7879
def updateColor(self):
7980
if self.isValid():
80-
self.SetForegroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT))
81+
self.SetForegroundColour(Colors.text())
8182
else:
8283
self.SetForegroundColour(wx.RED)
8384

0 commit comments

Comments
 (0)