fix: show interactive window when plot_wave_save_gif/mp4 are both 0
Use Agg backend and show=False only when saving to file. When neither gif nor mp4 is requested, show the animation window interactively. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+9
-5
@@ -381,15 +381,19 @@ def run_case(config_path, runtime_base, input_dir="input", output_dir="output",
|
|||||||
# 6. 波形能量动画(可选)
|
# 6. 波形能量动画(可选)
|
||||||
if config.get("step_plot_wave", 0):
|
if config.get("step_plot_wave", 0):
|
||||||
try:
|
try:
|
||||||
import matplotlib
|
_save_gif = int(config.get("plot_wave_save_gif", 0))
|
||||||
matplotlib.use("Agg") # 非交互式后端,避免弹窗/报错
|
_save_mp4 = int(config.get("plot_wave_save_mp4", 0))
|
||||||
|
_to_file = bool(_save_gif or _save_mp4)
|
||||||
|
if _to_file:
|
||||||
|
import matplotlib
|
||||||
|
matplotlib.use("Agg") # 保存文件时用非交互式后端
|
||||||
import plot_wave as pw
|
import plot_wave as pw
|
||||||
print("[run] 正在绘制波形与能量图…")
|
print("[run] 正在绘制波形与能量图…")
|
||||||
gif = pw.plot_wave(
|
gif = pw.plot_wave(
|
||||||
str(output_dir_abs),
|
str(output_dir_abs),
|
||||||
save_gif=int(config.get("plot_wave_save_gif", 0)),
|
save_gif=_save_gif,
|
||||||
save_mp4=int(config.get("plot_wave_save_mp4", 0)),
|
save_mp4=_save_mp4,
|
||||||
show=False,
|
show=not _to_file, # 不保存文件时弹出交互窗口
|
||||||
)
|
)
|
||||||
if gif:
|
if gif:
|
||||||
print(f"[run] 波形 GIF 已保存: {gif}")
|
print(f"[run] 波形 GIF 已保存: {gif}")
|
||||||
|
|||||||
Reference in New Issue
Block a user