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

Allow disabling the TTK theme through a command-line switch #512

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 modules/gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@


class PokebotGui:
def __init__(self, main_loop: callable, on_exit: callable):
if os.getenv("POKEBOT_UNTHEMED") != "1":
def __init__(self, main_loop: callable, on_exit: callable, no_theme: bool = False):
if not no_theme:
theme = "equilux" if darkdetect.isDark() else "clam"
self.window = ThemedTk(className="PokeBot", theme=theme)
else:
Expand Down
10 changes: 9 additions & 1 deletion pokebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import argparse
import atexit
import os
import pathlib
import platform
from dataclasses import dataclass
Expand Down Expand Up @@ -42,6 +43,7 @@ class StartupSettings:
headless: bool
no_video: bool
no_audio: bool
no_theme: bool
emulation_speed: int
always_on_top: bool
config_path: str
Expand Down Expand Up @@ -78,6 +80,7 @@ def parse_arguments(bot_mode_names: list[str]) -> StartupSettings:
parser.add_argument("-hl", "--headless", action="store_true", help="Run without a GUI, only using the console.")
parser.add_argument("-nv", "--no-video", action="store_true", help="Turn off video output by default.")
parser.add_argument("-na", "--no-audio", action="store_true", help="Turn off audio output by default.")
parser.add_argument("-nt", "--no-theme", action="store_true", help="Turn off the fancy GUI theme.")
parser.add_argument(
"-t", "--always-on-top", action="store_true", help="Keep the bot window always on top of other windows."
)
Expand All @@ -96,6 +99,7 @@ def parse_arguments(bot_mode_names: list[str]) -> StartupSettings:
headless=bool(args.headless),
no_video=bool(args.no_video),
no_audio=bool(args.no_audio),
no_theme=bool(args.no_theme),
emulation_speed=int(args.emulation_speed or "1"),
always_on_top=bool(args.always_on_top),
config_path=args.config_path,
Expand Down Expand Up @@ -144,7 +148,11 @@ def win32_signal_handler(signal_type):
else:
from modules.gui import PokebotGui

gui = PokebotGui(main_loop, on_exit)
# Previously, theming could _only_ be disabled through an environment flag. Now, it can
# be disabled using a command-line argument but for backward-compatibility reasons we
# accept either.
no_theme = os.getenv("POKEBOT_UNTHEMED") == "1" or startup_settings.no_theme
gui = PokebotGui(main_loop, on_exit, no_theme=no_theme)
context.gui = gui

gui.run(startup_settings)
Loading