Hi,
Werner F. Bruhin wrote:
I am trying to use a custom bitmap for the disabled state of toolbar icons.
self.myTB.AddLabelTool(label = _('Charts'),
bitmap = bmp,
bmpDisabled = bmpDA)Doing the above shows an error dialog "Couldn't add an image to the image list".
However all the tools show their correct icons.
If I replace "bmpDA" with wx.NullBitmap then I don't get the error, but this is obviously not what I want.
What am I doing wrong?
This is weird.
One of the tools I add is this:
self.wxId_myTBToolTip =wx.NewId()
bmp = images.getTog2Bitmap()
self.myTB.AddCheckLabelTool(label = ('Tool Tips'),
bitmap = bmp,
id = self.wxId_myTBToolTip,
longHelp = '',
shortHelp = '')
If I change this one to the following then it seems to work fine:
self.wxId_myTBToolTip =wx.NewId()
bmp = images.getTog2Bitmap()
self.myTB.AddCheckLabelTool(label = ('Tool Tips'),
bitmap = bmp,
bmpDisabled = bmpDA,
id = self.wxId_myTBToolTip,
longHelp = '',
shortHelp = '')
self.Bind(wx.EVT_TOOL, self.OnToolbarToolTip, id=self.wxId_myTBToolTip)
self.myTB.ToggleTool(self.wxId_myTBToolTip, True)
The strange thing is that if I change "bmpDA" on the above to wx.NullBitmap, or remove the "bmpDisabled = bmpDA," then I get the error again.
The minimum sample which causes the problem is having two tools as follows:
# Create Consumption Batch
self.wxId_myTBCreateBatch =wx.NewId()
img = myimages.getconsBatchImage()
bmp = wx.BitmapFromImage(img)
imgutil.grayOut(img)
bmpDA = wx.BitmapFromImage(img)
self.myTB.AddLabelTool(label = _('Create Consumption batch'),
bitmap = bmp,
bmpDisabled = bmpDA,
id = self.wxId_myTBCreateBatch,
longHelp = '',
shortHelp = '')
self.myTB.AddSeparator()
bmp = images.getTog2Bitmap()
self.wxId_myTBToolTip =wx.NewId()
self.myTB.AddCheckLabelTool(label = ('Tool Tips'),
bitmap = bmp,
bmpDisabled = bmpDA,
## bmpDisabled = wx.NullBitmap,
id = self.wxId_myTBToolTip,
longHelp = '',
shortHelp = '')
If you remove the bmpDiasbled on the second one I get the error or if I use the wx.NullBitmap version.
This was a pain to find, as the error doesn't even point to which tool is causing the problem.
This workaround does the trick for me, also not very nice.
Werner