MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / __init__

Method __init__

galleries/examples/widgets/menu.py:95–119  ·  view source on GitHub ↗
(self, fig, menuitems)

Source from the content-addressed store, hash-verified

93
94class Menu:
95 def __init__(self, fig, menuitems):
96 self.figure = fig
97
98 self.menuitems = menuitems
99
100 maxw = max(item.text_bbox.width for item in menuitems)
101 maxh = max(item.text_bbox.height for item in menuitems)
102 depth = max(-item.text_bbox.y0 for item in menuitems)
103
104 x0 = 1
105 y0 = 4
106
107 width = maxw + 2 * MenuItem.padx
108 height = maxh + MenuItem.pady
109
110 for item in menuitems:
111 left = x0
112 bottom = y0 - maxh - MenuItem.pady
113
114 item.set_extent(left, bottom, width, height, depth)
115
116 fig.artists.append(item)
117 y0 -= maxh + MenuItem.pady
118
119 fig.canvas.mpl_connect('motion_notify_event', self.on_move)
120
121 def on_move(self, event):
122 if any(item.set_hover(event) for item in self.menuitems):

Callers 1

__init__Method · 0.45

Calls 2

mpl_connectMethod · 0.80
set_extentMethod · 0.45

Tested by

no test coverage detected