在 wxpython 中一个接一个地切换工具栏小部件 4 次的逻辑是什么?

what is the logic to toggle toolbar widget 4 times one after the other in wxpython?

在这里,我尝试更改工具栏上单击的位图图像,

img = wx.Image('Image_A Path Here').Scale(50, 33, wx.IMAGE_QUALITY_HIGH)
face_tool = self.toolbar.AddTool(6, 'Animation', wx.Bitmap(img), 'Change Face Image')
self.on_face_click(None, init_face=True)
self.Bind(wx.EVT_TOOL, self.on_face_click, face_tool)

def on_face_click(self, event, init_face=False):
    if init_face:
        self.Test_face_click = False
    else:
        self.Test_face_click = not self.Test_face_click
    if self.Test_face_click:
        img = "Image_B Path Here"
        png = wx.Image(img, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        self.bottomToolbar.SetToolNormalBitmap(id=6, bitmap=png)
    else:
        img = "Image_A Path Here"
        png = wx.Image(img, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        self.bottomToolbar.SetToolNormalBitmap(id=6, bitmap=png)

我想在每次单击事件时一个接一个地更改位图图像 4 次。

请帮我解决这个逻辑。

self.btnImages= [ 'path of image_B', 'path of image_C','path of image_D','path of image_A']
self.img_index = 0
img = wx.Image('Image_A Path Here').Scale(55, 35, wx.IMAGE_QUALITY_HIGH)
b_face_tool = self.bottomToolbar.AddTool(id=6, 'Animation', wx.Bitmap(img))
self.Bind(wx.EVT_TOOL, self.on_face, b_face_tool)

def on_face(self, event):
    if (self.img_index == len(self.btnImages)):
        self.img_index = 0
    img = self.btnImages[self.img_index]
    self.bottomToolbar.SetToolNormalBitmap(id=6, bitmap=wx.Image(img, wx.BITMAP_TYPE_ANY).ConvertToBitmap())
    self.img_index = self.img_index + 1