Force interactive matplotlib backend in pick_barrier

Some environments default matplotlib to Agg (non-interactive), which
silently no-ops plt.show() — the picker would print "FigureCanvasAgg
is non-interactive" and never display the thumbnail grid. Probe TkAgg
> QtAgg > Qt5Agg > GTK3Agg before pyplot import.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Giorgio Gilestro 2026-05-01 12:23:15 +01:00
parent 2b75daa783
commit 24403e0474

View file

@ -41,6 +41,17 @@ import sys
from pathlib import Path
import cv2
import matplotlib
# Reason: force an interactive backend so plt.show() actually opens a window.
# Some environments (depending on matplotlibrc / DISPLAY / installed Qt-vs-Tk
# bindings) default to Agg, which silently no-ops the picker. Try the common
# GUI backends in order; fall through to whatever is set if none are available.
for _backend in ("TkAgg", "QtAgg", "Qt5Agg", "GTK3Agg"):
try:
matplotlib.use(_backend, force=True)
break
except (ImportError, ValueError):
continue
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd