Frage

I was wondering if it was possible to have tween animation in wxPython. I have tried looking at all the documentation but cannot seem to spot an reference to it. An example of what I am after would be having a button fly from the bottom of the window to the top. Is there such a way?

War es hilfreich?

Lösung

not exactly...

there is no magic tween function builtin to wx afaik, however you can use timers to create an update interval and animate it yourself

import wx
global btn
def updater():
    p = btn.GetPosition()
    btn.SetPosition((p[0] ,p[1] - 2))
    wx.CallLater(50,updater)
a= wx.App(redirect=False)

f = wx.Frame(None,-1,"Animation",size=(400,600))
p = wx.Panel(f,-1)
btn = wx.Button(p,-1,"Click Me",pos=(175,520))
f.Show()
wx.CallLater(50,updater) #could have used a normal timer just as easy ... maybe even easier
a.MainLoop()
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top