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:
@ -1,3 +1,5 @@
|
|||||||
|
import traceback
|
||||||
|
|
||||||
from pyqtgraph.exporters import MatplotlibExporter
|
from pyqtgraph.exporters import MatplotlibExporter
|
||||||
|
|
||||||
from bec_widgets.qt_utils.error_popups import SafeSlot, WarningPopupUtility
|
from bec_widgets.qt_utils.error_popups import SafeSlot, WarningPopupUtility
|
||||||
@ -60,7 +62,7 @@ class PlotExportBundle(ToolbarBundle):
|
|||||||
import matplotlib as mpl
|
import matplotlib as mpl
|
||||||
|
|
||||||
MatplotlibExporter(self.target_widget.plot_item).export()
|
MatplotlibExporter(self.target_widget.plot_item).export()
|
||||||
except:
|
except ModuleNotFoundError:
|
||||||
warning_util = WarningPopupUtility()
|
warning_util = WarningPopupUtility()
|
||||||
warning_util.show_warning(
|
warning_util.show_warning(
|
||||||
title="Matplotlib not installed",
|
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'.",
|
detailed_text="Please install matplotlib in your Python environment by using 'pip install matplotlib'.",
|
||||||
)
|
)
|
||||||
return
|
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
|
||||||
|
Reference in New Issue
Block a user