前提・実現したいこと
pythonのGUIであるwxpythonでwx.adv.Animationを使って、GIF再生による繰り返し回数を計測したいです。
様々なwx.EVT_を試しましたが、希望のものが分かりません。
どなたかわかる方いらっしゃいませんか?
よろしくお願いします。
import wx import wx.adv import time class GIF(object): def __init__(self,anime,id): self.counter = 0 self.anime = anime self.file ="1.gif" self.anime = anime self.ani = wx.adv.Animation(self.file) self.ctrl = wx.adv.AnimationCtrl(anime, -1, self.ani, pos=(10, 10)) self.ctrl.Bind(wx.EVT_???, self.update) #←ココに入るwx.EVTは何でしょうか? self.ctrl.Play() def update(self, event): self.counter = self.counter + 1 print(self.counter) #ここで再生回数を表示 time.sleep(0.01) class MyWindow(wx.Frame): def __init__(self, parent=None, id=-1, title=None): wx.Frame.__init__(self, parent, id, title) self.MainPanel = wx.Panel(self, size=(1200, 800))#メイン画面の大きさ self.anime = wx.Panel(self.MainPanel, pos=(750, 0),size=(450, 800)) self.anime.SetBackgroundColour("WHITE") self.Motion = GIF(self.anime, id) self.Fit() def CloseWindow(self, event): self.timer.Stop() wx.Exit() if __name__ == "__main__": app = wx.App() w = MyWindow(title="test") w.Center w.Show() app.MainLoop()
あなたの回答
tips
プレビュー