1
- import typing as typ
1
+ from plotly . utils import _list_repr_elided
2
2
3
3
4
4
class InputDeviceState :
5
- def __init__ (self , ctrl = None , alt = None , shift = None , meta = None , button = None , buttons = None , ** _ ):
5
+ def __init__ (self ,
6
+ ctrl = None ,
7
+ alt = None ,
8
+ shift = None ,
9
+ meta = None ,
10
+ button = None ,
11
+ buttons = None ,
12
+ ** _ ):
13
+
6
14
self ._ctrl = ctrl
7
15
self ._alt = alt
8
16
self ._meta = meta
@@ -12,15 +20,22 @@ def __init__(self, ctrl=None, alt=None, shift=None, meta=None, button=None, butt
12
20
13
21
def __repr__ (self ):
14
22
return """\
15
- InputState(ctrl={ctrl},
16
- alt={alt},
17
- shift={shift},
18
- meta={meta},
19
- button={button},
20
- buttons={buttons})"""
23
+ InputDeviceState(
24
+ ctrl={ctrl},
25
+ alt={alt},
26
+ shift={shift},
27
+ meta={meta},
28
+ button={button},
29
+ buttons={buttons})""" .format (
30
+ ctrl = repr (self .ctrl ),
31
+ alt = repr (self .alt ),
32
+ meta = repr (self .meta ),
33
+ shift = repr (self .shift ),
34
+ button = repr (self .button ),
35
+ buttons = repr (self .buttons ))
21
36
22
37
@property
23
- def alt (self ) -> bool :
38
+ def alt (self ):
24
39
"""
25
40
Whether alt key pressed
26
41
@@ -31,7 +46,7 @@ def alt(self) -> bool:
31
46
return self ._alt
32
47
33
48
@property
34
- def ctrl (self ) -> bool :
49
+ def ctrl (self ):
35
50
"""
36
51
Whether ctrl key pressed
37
52
@@ -42,7 +57,7 @@ def ctrl(self) -> bool:
42
57
return self ._ctrl
43
58
44
59
@property
45
- def shift (self ) -> bool :
60
+ def shift (self ):
46
61
"""
47
62
Whether shift key pressed
48
63
@@ -53,7 +68,7 @@ def shift(self) -> bool:
53
68
return self ._shift
54
69
55
70
@property
56
- def meta (self ) -> bool :
71
+ def meta (self ):
57
72
"""
58
73
Whether meta key pressed
59
74
@@ -64,12 +79,15 @@ def meta(self) -> bool:
64
79
return self ._meta
65
80
66
81
@property
67
- def button (self ) -> int :
82
+ def button (self ):
68
83
"""
69
- Integer code for the button that was pressed on the mouse to trigger the event
84
+ Integer code for the button that was pressed on the mouse to trigger
85
+ the event
70
86
71
- - 0: Main button pressed, usually the left button or the un-initialized state
72
- - 1: Auxiliary button pressed, usually the wheel button or the middle button (if present)
87
+ - 0: Main button pressed, usually the left button or the
88
+ un-initialized state
89
+ - 1: Auxiliary button pressed, usually the wheel button or the middle
90
+ button (if present)
73
91
- 2: Secondary button pressed, usually the right button
74
92
- 3: Fourth button, typically the Browser Back button
75
93
- 4: Fifth button, typically the Browser Forward button
@@ -81,9 +99,10 @@ def button(self) -> int:
81
99
return self ._button
82
100
83
101
@property
84
- def buttons (self ) -> int :
102
+ def buttons (self ):
85
103
"""
86
- Integer code for which combination of buttons are pressed on the mouse when the event is triggered.
104
+ Integer code for which combination of buttons are pressed on the
105
+ mouse when the event is triggered.
87
106
88
107
- 0: No button or un-initialized
89
108
- 1: Primary button (usually left)
@@ -92,9 +111,11 @@ def buttons(self) -> int:
92
111
- 8: 4th button (typically the "Browser Back" button)
93
112
- 16: 5th button (typically the "Browser Forward" button)
94
113
95
- Combinations of buttons are represented as the decimal form of the bitmask of the values above.
114
+ Combinations of buttons are represented as the decimal form of the
115
+ bitmask of the values above.
96
116
97
- For example, pressing both the primary (1) and auxilary (4) buttons will result in a code of 5
117
+ For example, pressing both the primary (1) and auxilary (4) buttons
118
+ will result in a code of 5
98
119
99
120
Returns
100
121
-------
@@ -105,31 +126,85 @@ def buttons(self) -> int:
105
126
106
127
class Points :
107
128
108
- def __init__ (self , point_inds = None , xs = None , ys = None , trace_name = None , trace_index = None ):
129
+ def __init__ (self ,
130
+ point_inds = None ,
131
+ xs = None ,
132
+ ys = None ,
133
+ trace_name = None ,
134
+ trace_index = None ):
135
+
109
136
self ._point_inds = point_inds
110
137
self ._xs = xs
111
138
self ._ys = ys
112
139
self ._trace_name = trace_name
113
140
self ._trace_index = trace_index
114
141
142
+ def __repr__ (self ):
143
+ return """\
144
+ Points(point_inds={point_inds},
145
+ xs={xs},
146
+ ys={ys},
147
+ trace_name={trace_name},
148
+ trace_index={trace_index})""" .format (
149
+ point_inds = _list_repr_elided (self .point_inds ),
150
+ xs = _list_repr_elided (self .xs ),
151
+ ys = _list_repr_elided (self .ys ),
152
+ trace_name = repr (self .trace_name ),
153
+ trace_index = repr (self .trace_index ))
154
+
115
155
@property
116
- def point_inds (self ) -> typ .List [int ]:
156
+ def point_inds (self ):
157
+ """
158
+ List of selected indexes into the trace's points
159
+
160
+ Returns
161
+ -------
162
+ list[int]
163
+ """
117
164
return self ._point_inds
118
165
119
166
@property
120
- def xs (self ) -> typ .List :
167
+ def xs (self ):
168
+ """
169
+ List of x-coordinates of selected points
170
+
171
+ Returns
172
+ -------
173
+ list[float]
174
+ """
121
175
return self ._xs
122
176
123
177
@property
124
- def ys (self ) -> typ .List :
178
+ def ys (self ):
179
+ """
180
+ List of y-coordinates of selected points
181
+
182
+ Returns
183
+ -------
184
+ list[float]
185
+ """
125
186
return self ._ys
126
187
127
188
@property
128
- def trace_name (self ) -> str :
189
+ def trace_name (self ):
190
+ """
191
+ Name of the trace
192
+
193
+ Returns
194
+ -------
195
+ str
196
+ """
129
197
return self ._trace_name
130
198
131
199
@property
132
- def trace_index (self ) -> int :
200
+ def trace_index (self ):
201
+ """
202
+ Index of the trace in the figure
203
+
204
+ Returns
205
+ -------
206
+ int
207
+ """
133
208
return self ._trace_index
134
209
135
210
@@ -139,16 +214,44 @@ def __init__(self, xrange=None, yrange=None, **_):
139
214
self ._xrange = xrange
140
215
self ._yrange = yrange
141
216
217
+ def __repr__ (self ):
218
+ return """\
219
+ BoxSelector(xrange={xrange},
220
+ yrange={yrange})""" .format (
221
+ xrange = self .xrange ,
222
+ yrange = self .yrange )
223
+
142
224
@property
143
- def type (self ) -> str :
225
+ def type (self ):
226
+ """
227
+ The selector's type
228
+
229
+ Returns
230
+ -------
231
+ str
232
+ """
144
233
return self ._type
145
234
146
235
@property
147
- def xrange (self ) -> typ .Tuple [float , float ]:
236
+ def xrange (self ):
237
+ """
238
+ x-axis range extents of the box selection
239
+
240
+ Returns
241
+ -------
242
+ (float, float)
243
+ """
148
244
return self ._xrange
149
245
150
246
@property
151
- def yrange (self ) -> typ .Tuple [float , float ]:
247
+ def yrange (self ):
248
+ """
249
+ y-axis range extents of the box selection
250
+
251
+ Returns
252
+ -------
253
+ (float, float)
254
+ """
152
255
return self ._yrange
153
256
154
257
@@ -158,14 +261,44 @@ def __init__(self, xs=None, ys=None, **_):
158
261
self ._xs = xs
159
262
self ._ys = ys
160
263
264
+ def __repr__ (self ):
265
+ return """\
266
+ LassoSelector(xs={xs},
267
+ ys={ys})""" .format (
268
+ xs = _list_repr_elided (self .xs , 8 ),
269
+ ys = _list_repr_elided (self .ys , 8 ))
270
+
161
271
@property
162
- def type (self ) -> str :
272
+ def type (self ):
273
+ """
274
+ The selector's type
275
+
276
+ Returns
277
+ -------
278
+ str
279
+ """
163
280
return self ._type
164
281
165
282
@property
166
- def xs (self ) -> typ .List [float ]:
283
+ def xs (self ):
284
+ """
285
+ list of x-axis coordinates of each point in the lasso selection
286
+ boundary
287
+
288
+ Returns
289
+ -------
290
+ list[float]
291
+ """
167
292
return self ._xs
168
293
169
294
@property
170
- def ys (self ) -> typ .List [float ]:
295
+ def ys (self ):
296
+ """
297
+ list of y-axis coordinates of each point in the lasso selection
298
+ boundary
299
+
300
+ Returns
301
+ -------
302
+ list[float]
303
+ """
171
304
return self ._ys
0 commit comments