0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-14 11:41:49 +02:00

fix(plot_base): improved handling of matplotlib exporter errors

This commit is contained in:
2025-03-13 12:42:55 +01:00
parent 339e0152ff
commit c2f8f285a8

View File

@ -1,3 +1,5 @@
import traceback
from pyqtgraph.exporters import MatplotlibExporter
from bec_widgets.qt_utils.error_popups import SafeSlot, WarningPopupUtility
@ -60,7 +62,7 @@ class PlotExportBundle(ToolbarBundle):
import matplotlib as mpl
MatplotlibExporter(self.target_widget.plot_item).export()
except:
except ModuleNotFoundError:
warning_util = WarningPopupUtility()
warning_util.show_warning(
title="Matplotlib not installed",
@ -68,3 +70,12 @@ class PlotExportBundle(ToolbarBundle):
detailed_text="Please install matplotlib in your Python environment by using 'pip install matplotlib'.",
)
return
except TypeError:
warning_util = WarningPopupUtility()
error_msg = traceback.format_exc()
warning_util.show_warning(
title="Matplotlib TypeError",
message="Matplotlib exporter could not resolve the plot item.",
detailed_text=error_msg,
)
return