python - wxpython在wxpython staticbitmap中刷新图像

标签 python wxpython wxwidgets

我需要你的帮助,以刷新和更改 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/

相关文章:

python - 如何制作随机唯一元组列表?

python - 使用 shlex 保留连续的空格

c++ - wxDataViewModel : What is it and how do i use it?

python - wx.TextCtrl 中插入点位置的弹出菜单

python - 单击 : "Got unexpected extra arguments" when passing string

python - 如何告诉 pip 在安装我的包时创建文件夹

python - 在 wxPython 中使用线程将面板添加到 GUI

python - 如何在 wxPython 中将 StatusBar 中的文本右对齐?

python - wxPython:如何在多行 TextCtrl 上监听 EVT_CHAR 事件?

c++ - wxWidgets 有某种垃圾收集器吗?