MCPcopy Create free account
hub / github.com/Image-Py/imagepy / add_tools

Function add_tools

imagepy/ui/toolsloader.py:98–124  ·  view source on GitHub ↗
(bar, datas, clear=False, curids=[])

Source from the content-addressed store, hash-verified

96 tol().view(btn)
97
98def add_tools(bar, datas, clear=False, curids=[]):
99 box = bar.GetSizer()
100 if not clear:
101 for curid in curids:
102 #bar.RemoveChild(curid)
103 #box.Hide(curid)
104 curid.Destroy()
105 #box.Detach(curid)
106 del curids[:]
107
108 for data in datas:
109 btn = wx.BitmapButton(bar, wx.ID_ANY, make_bitmap(wx.Bitmap(data[1])),
110 wx.DefaultPosition, (32,32), wx.BU_AUTODRAW|wx.RAISED_BORDER )
111 if not clear:curids.append(btn)
112 if clear: box.Add(btn)
113 else:
114 box.Insert(len(box.GetChildren())-2, btn)
115
116 btn.Bind( wx.EVT_LEFT_DOWN, lambda x, p=data[0]:f(p(), x))
117 btn.Bind( wx.EVT_RIGHT_DOWN, lambda x, p=data[0]: IPy.show_md(p.title, DocumentManager.get(p.title)))
118 btn.Bind( wx.EVT_ENTER_WINDOW,
119 lambda x, p='"{}" Tool'.format(data[0].title): set_info(p))
120 if not isinstance(data[0], Macros) and issubclass(data[0], Tool):
121 btn.Bind(wx.EVT_LEFT_DCLICK, lambda x, p=data[0]:p().show())
122 btn.SetDefault()
123 box.Layout()
124 bar.Refresh()

Callers 2

buildToolsBarFunction · 0.85
menu_dropFunction · 0.85

Calls 7

appendMethod · 0.80
make_bitmapFunction · 0.70
fFunction · 0.70
set_infoFunction · 0.70
BindMethod · 0.45
getMethod · 0.45
showMethod · 0.45

Tested by

no test coverage detected