我需要你的帮助,以刷新和更改 wxpython 中的静态位图图像而不相互重叠,我正在用 python 构建一个 slotmachine 程序但是我遇到了静态位图堆叠在彼此之上的问题,每当我旋转轮子时显示图像的老虎机...见下图,提前谢谢。
截图在这里--> http://s2.postimg.org/434h21t2x/problem.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))
在您的代码中您没有引用任何静态位图。所以你可能想改变它,这样你就可以把新的照片放进去。
关于python - wxpython在wxpython staticbitmap中刷新图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30841181/