mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-21 11:27:38 +03:00
theme.py: Implement a ttk.Style, re-using self.current
settings
Currently this only sets foreground and background colors, as that's all we need for `ttk.Sizegrip` to look correct in all themes.
This commit is contained in:
parent
b2b2fcbaf6
commit
f014fbd525
15
theme.py
15
theme.py
@ -115,6 +115,7 @@ elif sys.platform == 'linux':
|
||||
class _Theme(object):
|
||||
|
||||
def __init__(self):
|
||||
self.ttk_style = None
|
||||
self.active = None # Starts out with no theme
|
||||
self.minwidth = None
|
||||
self.widgets = {}
|
||||
@ -184,6 +185,10 @@ class _Theme(object):
|
||||
for child in widget.winfo_children():
|
||||
self.register(child)
|
||||
|
||||
# This class is an import-time singleton, so can't do this in __init__
|
||||
# as tkinter won't have been at all set up by then.
|
||||
self.ttk_style = ttk.Style()
|
||||
|
||||
def register_alternate(self, pair, gridopts):
|
||||
self.widgets_pair.append((pair, gridopts))
|
||||
|
||||
@ -431,6 +436,16 @@ class _Theme(object):
|
||||
self.minwidth = root.winfo_width() # Minimum width = width on first creation
|
||||
root.minsize(self.minwidth, -1)
|
||||
|
||||
#######################################################################
|
||||
# Update our ttk.Style
|
||||
#
|
||||
# Ref: <https://stackoverflow.com/a/54476816>
|
||||
# Ref: <https://tkdocs.com/shipman/ttk-style-layer.html>
|
||||
######################################################################
|
||||
self.ttk_style.configure('TSizegrip', background=self.current['background'])
|
||||
self.ttk_style.configure('TSizegrip', foreground=self.current['foreground'])
|
||||
#######################################################################
|
||||
|
||||
|
||||
# singleton
|
||||
theme = _Theme()
|
||||
|
Loading…
x
Reference in New Issue
Block a user