fix: lazy-import tkinter to fix CI on headless Linux
Some checks failed
Lint & Test / test (push) Failing after 2m16s
Some checks failed
Lint & Test / test (push) Failing after 2m16s
screen_overlay.py imported tkinter at module level, which cascaded through processor_manager → every test touching the app on CI where libtk8.6.so is unavailable. Move to TYPE_CHECKING + runtime lazy import so the overlay module loads cleanly on headless systems. Also fix test_processor_manager.py to use ProcessorDependencies().
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
"""Screen overlay visualization for LED calibration testing."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import colorsys
|
||||
import logging
|
||||
import sys
|
||||
import threading
|
||||
import tkinter as tk
|
||||
from typing import Dict, List, Optional
|
||||
from typing import TYPE_CHECKING, Dict, List, Optional
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import tkinter as tk
|
||||
|
||||
from wled_controller.core.capture.calibration import CalibrationConfig
|
||||
from wled_controller.core.capture_engines.base import DisplayInfo
|
||||
@@ -44,6 +48,8 @@ class OverlayWindow:
|
||||
|
||||
def start(self, root: tk.Tk) -> None:
|
||||
"""Create and show the overlay Toplevel (runs in Tk thread)."""
|
||||
import tkinter as tk # lazy import — tkinter unavailable in headless CI
|
||||
|
||||
self._window = tk.Toplevel(root)
|
||||
self._setup_window()
|
||||
self._draw_visualization()
|
||||
@@ -74,6 +80,8 @@ class OverlayWindow:
|
||||
win.overrideredirect(True)
|
||||
win.attributes("-topmost", True)
|
||||
|
||||
import tkinter as tk
|
||||
|
||||
self._canvas = tk.Canvas(
|
||||
win,
|
||||
width=self.display_info.width,
|
||||
@@ -270,6 +278,8 @@ class OverlayManager:
|
||||
|
||||
def _start_tk_thread(self) -> None:
|
||||
def _run():
|
||||
import tkinter as tk # lazy import — tkinter unavailable in headless CI
|
||||
|
||||
try:
|
||||
self._tk_root = tk.Tk()
|
||||
self._tk_root.withdraw() # invisible root — never shown
|
||||
|
||||
Reference in New Issue
Block a user