2121
2222import matplotlib .artist as martist
2323from matplotlib .artist import Artist , allow_rasterization
24- from matplotlib .backend_bases import FigureCanvasBase , NonGuiException
24+ from matplotlib .backend_bases import (
25+ FigureCanvasBase , NonGuiException , MouseButton )
2526import matplotlib .cbook as cbook
2627import matplotlib .colorbar as cbar
2728import matplotlib .image as mimage
@@ -2233,8 +2234,10 @@ def subplots_adjust(self, left=None, bottom=None, right=None, top=None,
22332234 ax .set_position (ax .figbox )
22342235 self .stale = True
22352236
2236- def ginput (self , n = 1 , timeout = 30 , show_clicks = True , mouse_add = 1 ,
2237- mouse_pop = 3 , mouse_stop = 2 ):
2237+ def ginput (self , n = 1 , timeout = 30 , show_clicks = True ,
2238+ mouse_add = MouseButton .LEFT ,
2239+ mouse_pop = MouseButton .RIGHT ,
2240+ mouse_stop = MouseButton .MIDDLE ):
22382241 """
22392242 Blocking call to interact with a figure.
22402243
@@ -2248,13 +2251,7 @@ def ginput(self, n=1, timeout=30, show_clicks=True, mouse_add=1,
22482251 - Stop the interaction and return the points added so far.
22492252
22502253 The actions are assigned to mouse buttons via the arguments
2251- *mouse_add*, *mouse_pop* and *mouse_stop*. Mouse buttons are defined
2252- by the numbers:
2253-
2254- - 1: left mouse button
2255- - 2: middle mouse button
2256- - 3: right mouse button
2257- - None: no mouse button
2254+ *mouse_add*, *mouse_pop* and *mouse_stop*.
22582255
22592256 Parameters
22602257 ----------
@@ -2266,11 +2263,11 @@ def ginput(self, n=1, timeout=30, show_clicks=True, mouse_add=1,
22662263 will never timeout.
22672264 show_clicks : bool, default: True
22682265 If True, show a red cross at the location of each click.
2269- mouse_add : {1, 2, 3, None} , default: 1 (left click)
2266+ mouse_add : `.MouseButton` or None, default: `.MouseButton.LEFT`
22702267 Mouse button used to add points.
2271- mouse_pop : {1, 2, 3, None} , default: 3 (right click)
2268+ mouse_pop : `.MouseButton` or None, default: `.MouseButton.RIGHT`
22722269 Mouse button used to remove the most recently added point.
2273- mouse_stop : {1, 2, 3, None} , default: 2 (middle click)
2270+ mouse_stop : `.MouseButton` or None, default: `.MouseButton.MIDDLE`
22742271 Mouse button used to stop input.
22752272
22762273 Returns
0 commit comments