This commit introduces CLI arg `--dark`, which toggles dark mode. The
effect should be like https://fkfd.me/static/mcross_dark.png
---
src/mcross/__init__.py | 1 +
src/mcross/gui/controller.py | 4 +++-
src/mcross/gui/view.py | 10 +++++-----
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/mcross/__init__.py b/src/mcross/__init__.py
index 200999f..eb8be0e 100644
--- a/src/mcross/__init__.py
+++ b/src/mcross/__init__.py
@@ -9,6 +9,7 @@ def run():
argparser = argparse.ArgumentParser()
argparser.add_argument("--textfont")
argparser.add_argument("--monofont")
+ argparser.add_argument("--dark", action="store_true")
args = argparser.parse_args()
# Actually start the program
diff --git a/src/mcross/gui/controller.py b/src/mcross/gui/controller.py
index 92d59c7..ca6b684 100644
--- a/src/mcross/gui/controller.py
+++ b/src/mcross/gui/controller.py
@@ -25,7 +25,9 @@ class Controller:
self.root = Tk()
self.root.alt_shortcuts = set()
self.model = Model()
- self.view = View(self.root, self.model, fonts=(args.textfont, args.monofont))
+ self.view = View(
+ self.root, self.model, fonts=(args.textfont, args.monofont), dark=args.dark
+ )
self.root.title("McRoss Browser")
self.root.geometry("800x600")
diff --git a/src/mcross/gui/view.py b/src/mcross/gui/view.py
index a52f30c..7e5ed33 100644
--- a/src/mcross/gui/view.py
+++ b/src/mcross/gui/view.py
@@ -71,7 +71,7 @@ class View:
back_callback = None
forward_callback = None
- def __init__(self, root: Tk, model: Model, fonts=(None, None)):
+ def __init__(self, root: Tk, model: Model, fonts=(None, None), dark=False):
self.model = model
# first row - address bar + buttons
@@ -165,8 +165,8 @@ class View:
text.config(
font=(text_font, 13),
- bg="#fff8dc",
- fg="black",
+ bg="#212121" if dark else "#fff8dc",
+ fg="#eee" if dark else "black",
padx=5,
pady=5,
# hide blinking insertion cursor:
@@ -176,12 +176,12 @@ class View:
height=1,
)
text.pack(side="left", fill="both", expand=True)
- text.tag_config("link", foreground="brown")
+ text.tag_config("link", foreground="#ff8a65" if dark else "brown")
text.tag_bind("link", "<Enter>", self._on_link_enter)
text.tag_bind("link", "<Leave>", self._on_link_leave)
text.tag_bind("link", "<Button-1>", self._on_link_click)
text.tag_config("pre", font=(mono_font, 13))
- text.tag_config("listitem", foreground="#044604")
+ text.tag_config("listitem", foreground="#64c664" if dark else "#044604")
base_heading_font = font.Font(font=text["font"])
base_heading_font.config(weight="bold")
--
2.27.0
Looks good to me. Merging it now, thanks!
However you probably shouldn't put too much effort into cosmetic
personalization for now, since I plan to implement some sort of conf
file / cli arg configuration scheme which will be more granular
(--h1-font, --h1-color, --list-size etc.)