我需要你的帮助,在wxpython中刷新和改变静态位图图像而不互相叠加,我在python中建立了一个slotmachine程序,但我遇到了一个问题,每当我旋转slotmachine的轮子来显示图像时,静态位图就会互相叠加......见下图,提前告知。
截图在这里--> http:/s2.postimg.org434h21t2xproblem.png
wheel_faces = controller.show_wheel_faces()
image_list = {"CHERRY":"resources/cherry.png", "ORANGE":"resources/orange.png",
"7":"resources/seven.png", "COIN":"resources/coin.png",
"CLOWN":"resources/clown.png", "APPLE":"resources/apple.png"}
if wheel_faces != []:
#print wheel_faces
wheel1 = wx.EmptyImage()
wheel1 = wx.Image(image_list.get(wheel_faces[0]),
wx.BITMAP_TYPE_PNG).ConvertToBitmap()
wx.StaticBitmap(self, -1, wheel1, pos=(135, 272))
wheel2 = wx.Image(image_list.get(wheel_faces[1]),
wx.BITMAP_TYPE_PNG).ConvertToBitmap()
wx.StaticBitmap(self, -1, wheel2, pos=(276, 272))
wheel3 = wx.Image(image_list.get(wheel_faces[2]),
wx.BITMAP_TYPE_PNG).ConvertToBitmap()
wx.StaticBitmap(self, -1, wheel3, pos=(415, 272))
self.Refresh()
self.account_balance += int(controller.show_winnings())
if controller.show_winnings() != 0:
self.payout_label.SetLabel(str(self.account_balance))
self.spin_label.SetLabel(str(controller.show_winnings()))
#print controller.balance_manager()
self.Refresh()
你需要用新的图片更新wx.StaticBitmap。
命令是
someStaticBitmap.SetBitmap(wx.Bitmap(self.img))
在你的代码中,你没有引用任何静态位图。所以你可能想改变它,这样你就可以把新的图片放在里面。