@@ -177,6 +177,42 @@ def test_never_update():
177
177
# checks them.
178
178
179
179
180
+ @pytest .mark .backend ('TkAgg' , skip_on_importerror = True )
181
+ @_isolated_tk_test (success_count = 1 )
182
+ def test_toolbar_button_la_mode_icon ():
183
+ # test that icon in LA mode can be used for buttons
184
+ # see GH#25164
185
+ import tempfile
186
+ import warnings
187
+
188
+ from PIL import Image
189
+
190
+ import matplotlib
191
+ import matplotlib .pyplot as plt
192
+ from matplotlib .backend_tools import ToolToggleBase
193
+
194
+ # tweaking toolbar raises an UserWarning
195
+ with warnings .catch_warnings ():
196
+ warnings .simplefilter ("ignore" , UserWarning )
197
+ matplotlib .rcParams ["toolbar" ] = "toolmanager"
198
+
199
+ # create an icon in LA mode
200
+ with tempfile .TemporaryDirectory () as tempdir :
201
+ img = Image .new ("LA" , (26 , 26 ))
202
+ tmp_img_path = os .path .join (tempdir , "test_la_icon.png" )
203
+ img .save (tmp_img_path )
204
+
205
+ class CustomTool (ToolToggleBase ):
206
+ image = tmp_img_path
207
+
208
+ fig = plt .figure ()
209
+ toolmanager = fig .canvas .manager .toolmanager
210
+ toolbar = fig .canvas .manager .toolbar
211
+ toolmanager .add_tool ("test" , CustomTool )
212
+ toolbar .add_tool ("test" , "group" )
213
+ print ("success" )
214
+
215
+
180
216
@_isolated_tk_test (success_count = 2 )
181
217
def test_missing_back_button ():
182
218
import matplotlib .pyplot as plt
0 commit comments