def add_tools(bar, datas, curids=[]):
##! TODO:
## datas? dirpath tree to generate menus/toolsbar?
## curids? ??
box = bar.GetSizer()
if curids!=None:
for curid in curids:
bar.RemoveChild(curid)
box.Hide(curid)
box.Detach(curid)
if curids!=None:
del curids[:]
for data in datas:
btn = wx.BitmapButton(bar, wx.ID_ANY,
make_bitmap(wx.Bitmap(data[1])),
wx.DefaultPosition, (32,32),
wx.BU_AUTODRAW|wx.RAISED_BORDER )
if curids!=None:
curids.append(btn)
if curids==None:
box.Add(btn)
else:
box.Insert(len(box.GetChildren())-2, btn)
btn.Bind( wx.EVT_LEFT_DOWN, lambda x, p=data[0]:f(p(), x))
btn.Bind( wx.EVT_ENTER_WINDOW,
lambda x, p='"{}" Tool'.format(data[0].title): set_info(p))
if not isinstance(data[0], Macros) and issubclass(data[0], Tool):
btn.Bind(wx.EVT_LEFT_DCLICK, lambda x, p=data[0]:p().show())
btn.SetDefault()
box.Layout()
bar.Refresh()
if curids==None:
sp = wx.StaticLine( bar, wx.ID_ANY,
wx.DefaultPosition, wx.DefaultSize, wx.LI_VERTICAL )
box.Add( sp, 0, wx.ALL|wx.EXPAND, 2 )
box.AddStretchSpacer(1)
评论列表
文章目录