Skip to content

Commit 4c5f8e1

Browse files
committed
Bump GitHub Actions and refine help banner
Update CI steps to use actions/checkout@v6 and actions/setup-python@v6. Revise ASCII help banner generation: import LOGO_ALPHA from the theme, remove static resource path, add max_width parameter, compute banner width from terminal size (clamped between min_width and max_width), and skip rendering the banner when stdout is not a TTY. Simplifies banner selection logic and keeps colored banner output when available.
1 parent 7230f69 commit 4c5f8e1

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

.github/workflows/python-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ jobs:
8888
if: ${{ startsWith(github.ref, 'refs/tags/v') }} # only on tag pushes like v1.2.3
8989
steps:
9090
- name: Checkout
91-
uses: actions/checkout@v4
91+
uses: actions/checkout@v6
9292

9393
- name: Setup Python
94-
uses: actions/setup-python@v5
94+
uses: actions/setup-python@v6
9595
with:
9696
python-version: "3.x"
9797

dlclivegui/assets/ascii_art.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818
import shutil
1919
import sys
2020
from collections.abc import Iterable
21-
from importlib import resources
2221
from typing import Literal
2322

2423
import numpy as np
2524

25+
from dlclivegui.gui.theme import LOGO_ALPHA
26+
2627
try:
2728
import cv2 as cv
2829
except Exception as e: # pragma: no cover
@@ -381,11 +382,10 @@ def print_ascii(
381382
# -----------------------------
382383
# Optional: Help banner helpers
383384
# -----------------------------
384-
ASCII_IMAGE_PATH = resources.files("dlclivegui.assets") / "logo_transparent.png"
385385

386386

387387
def build_help_description(
388-
static_banner: str | None = None, *, desc=None, color: ColorMode = "auto", min_width: int = 60
388+
static_banner: str | None = None, *, desc=None, color: ColorMode = "auto", min_width: int = 60, max_width: int = 120
389389
) -> str:
390390
"""Return a help description string that conditionally includes a colored ASCII banner.
391391
@@ -395,12 +395,20 @@ def build_help_description(
395395
"""
396396
enable_windows_ansi_support()
397397
desc = "DeepLabCut-Live GUI — launch the graphical interface." if desc is None else desc
398-
if static_banner is None:
398+
if not sys.stdout.isatty() and terminal_is_wide_enough(min_width=min_width):
399+
return desc
400+
401+
banner: str | None
402+
if static_banner is not None:
403+
banner = static_banner
404+
else:
399405
try:
406+
term_width = get_terminal_width(default=max_width)
407+
width = max(min(term_width, max_width), min_width)
400408
banner = "\n".join(
401409
generate_ascii_lines(
402-
str(ASCII_IMAGE_PATH),
403-
width=shutil.get_terminal_size((80, 24)).columns - 10,
410+
str(LOGO_ALPHA),
411+
width=width,
404412
aspect=0.5,
405413
color=color,
406414
fine=True,
@@ -414,9 +422,8 @@ def build_help_description(
414422
)
415423
except (FileNotFoundError, RuntimeError, OSError):
416424
banner = None
417-
else:
418-
banner = static_banner
419-
if banner and terminal_is_wide_enough(min_width=min_width):
425+
426+
if banner:
420427
if should_use_color(color):
421428
banner = f"\x1b[36m{banner}\x1b[0m"
422429
return banner + "\n" + desc

0 commit comments

Comments
 (0)