neural-amp-modeler

Neural network emulator for guitar amplifiers
Log | Files | Refs | README | LICENSE

commit 959cdf8d92e6d4fc9b7496c7973fc8c1227c492b
parent 30d693e535a29c7643dd9a3695774e51b570bce9
Author: Steven Atkinson <[email protected]>
Date:   Fri, 24 May 2024 11:36:56 -0700

Fix system text color (#429)

* Test highlighting the issue

* Fix

* GitHub tests

* xvfb for GitHub testing

* sudo

* Not needed

* One last change back

* Fix for Linux
Diffstat:
M.github/workflows/python-package.yml | 2+-
Mnam/train/core.py | 5++++-
Mnam/train/gui/__init__.py | 10+++++++++-
Atests/test_nam/test_train/test_gui.py | 23+++++++++++++++++++++++
4 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml @@ -38,4 +38,4 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest run: | - pytest + xvfb-run -a pytest diff --git a/nam/train/core.py b/nam/train/core.py @@ -919,7 +919,10 @@ def _get_data_config( train_stop = validation_start validation_stop = validation_start + data_info.t_validate train_kwargs = {"stop_samples": train_stop} - validation_kwargs = {"start_samples": validation_start, "stop_samples": validation_stop} + validation_kwargs = { + "start_samples": validation_start, + "stop_samples": validation_stop, + } elif data_info.major_version == 3: validation_start = data_info.validation_start train_stop = validation_start diff --git a/nam/train/gui/__init__.py b/nam/train/gui/__init__.py @@ -27,6 +27,7 @@ _ensure_graceful_shutdowns() import re import tkinter as tk +import sys import webbrowser from dataclasses import dataclass from enum import Enum @@ -78,6 +79,13 @@ _ADVANCED_OPTIONS_RIGHT_WIDTH = 12 _METADATA_RIGHT_WIDTH = 60 +def _is_mac() -> bool: + return sys.platform == "darwin" + + +_SYSTEM_TEXT_COLOR = "systemTextColor" if _is_mac() else "black" + + @dataclass class _AdvancedOptions(object): """ @@ -117,7 +125,7 @@ class _PathButton(object): path_key: settings.PathKey, hooks: Optional[Sequence[Callable[[], None]]] = None, color_when_not_set: str = "#EF0000", # Darker red - color_when_set: str = "systemTextColor", + color_when_set: str = _SYSTEM_TEXT_COLOR, default: Optional[Path] = None, ): """ diff --git a/tests/test_nam/test_train/test_gui.py b/tests/test_nam/test_train/test_gui.py @@ -0,0 +1,23 @@ +# File: test_gui.py +# Created Date: Friday May 24th 2024 +# Author: Steven Atkinson ([email protected]) + +import tkinter as tk + +import pytest + +from nam.train import gui + + +class TestPathButton(object): + def test_system_text_color(self): + """ + Issue 428 + """ + top_level = tk.Toplevel() + label = tk.Label(master=top_level, text="My text", fg=gui._SYSTEM_TEXT_COLOR) + label.pack() + + +if __name__ == "__main__": + pytest.main()