3535if TYPE_CHECKING :
3636 from guidata .dataset import DataSet
3737
38+ from plotpy .items import BaseImageItem
39+ from plotpy .plot import BasePlot
40+
3841
3942def _create_choices (
4043 dataset : DataSet , item : ImageChoiceItem , value : Any
@@ -102,13 +105,16 @@ class BaseImageParam(DataSet):
102105 zformat = StringItem (_ ("Z-Axis" ), default = r"%.1f" )
103106 _end_formats = EndGroup (_ ("Statistics string formatting" ))
104107
105- def update_param (self , image ) :
106- """
108+ def update_param (self , image : BaseImageItem ) -> None :
109+ """Update the parameters from the given image item.
107110
108- :param image:
111+ Args:
112+ image: The image item to update the parameters from.
109113 """
110114 self .label = str (image .title ().text ())
111- self .colormap = image .get_color_map_name ()
115+ cmap = image .get_color_map ()
116+ if cmap is not None :
117+ self .colormap = cmap .name
112118 interpolation = image .get_interpolation ()
113119 mode = interpolation [0 ]
114120
@@ -120,14 +126,15 @@ def update_param(self, image):
120126 size = interpolation [1 ].shape [0 ]
121127 self .interpolation = size
122128
123- def update_item (self , image ) :
124- """
129+ def update_item (self , image : BaseImageItem ) -> None :
130+ """Update the given image item from the parameters.
125131
126- :param image:
132+ Args:
133+ image: The image item to update.
127134 """
128135 if isinstance (self .alpha_function , LUTAlpha ):
129136 self .alpha_function = self .alpha_function .value
130- plot = image .plot ()
137+ plot : BasePlot = image .plot ()
131138 if plot is not None :
132139 plot .blockSignals (True ) # Avoid unwanted calls of update_param
133140 # triggered by the setter methods below
@@ -192,23 +199,27 @@ class QuadGridParam(DataSet):
192199 grid = BoolItem (_ ("Show grid" ), default = False )
193200 gridcolor = ColorItem (_ ("Grid lines color" ), default = "black" )
194201
195- def update_param (self , image ) :
196- """
202+ def update_param (self , image : BaseImageItem ) -> None :
203+ """Update the parameters from the given image item.
197204
198- :param image:
205+ Args:
206+ image: The image item to update the parameters from.
199207 """
200208 self .label = str (image .title ().text ())
201- self .colormap = image .get_color_map_name ()
209+ cmap = image .get_color_map ()
210+ if cmap is not None :
211+ self .colormap = cmap .name
202212 interp , uflat , vflat = image .interpolate
203213 self .interpolation = interp
204214 self .uflat = uflat
205215 self .vflat = vflat
206216 self .grid = image .grid
207217
208- def update_item (self , image ) :
209- """
218+ def update_item (self , image : BaseImageItem ) -> None :
219+ """Update the given image item from the parameters.
210220
211- :param image:
221+ Args:
222+ image: The image item to update.
212223 """
213224 if isinstance (self .alpha_function , LUTAlpha ):
214225 self .alpha_function = self .alpha_function .value
0 commit comments