The null bitmap is forbidden from 4.1

Hi there,

Does anyone know how to create a null bitmap or how to clear the bitmap set on the button object?

I’m using platebtn and changing the icon to null bitmap at run-time like this:

In the sample code, wx.Bitmap(0,0) is used as null bitmap. There is no problem up to wx version 4.0.7. However, since 4.1.0 it fails with Assertion error.

import wx
import wx.lib.platebtn as pb

class Panel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        self.btn = pb.PlateButton(self, label="test", size=(60,-1))
        icon = wx.ArtProvider.GetBitmap(wx.ART_TICK_MARK)
        self.btn.SetBitmap(icon) # ok
        ## self.btn.SetBitmap(wx.Bitmap()) # NG
        ## self.btn.SetBitmap(wx.NullBitmap) # NG
        self.btn.SetBitmap(wx.Bitmap(0,0)) # NG... from 4.1.0

if __name__ == "__main__":
    app = wx.App()
    frm = wx.Frame(None)
    panel = Panel(frm)

I think app.SetAssertMode(wx.APP_ASSERT_SUPPRESS) is one of the options, but not preferable.
I appreciate any adivice.
Thanks in advance!

How about a bitmap that has just one transparent pixel?

        data = bytearray((0,0,0))
        alpha = bytearray((0,))
        image = wx.Image(1, 1, data, alpha)
        bmp = image.ConvertToBitmap()


class MyPlateButton(pb.PlateButton):

    def ClearBitmap(self):
        self._bmp = dict(enable=None, disable=None)

Thanks for the idea, Richard. It looks fine!
This can be simplified a bit.

bmp = wx.Bitmap(1,1)

I found this code from here.

For my purpose, though limited to the platebtn, this looks like the best solution.

Many thanks!