【问题标题】:Animated gif with wxpython phoenix带有 wxpython phoenix 的动画 gif
【发布时间】:2018-08-29 14:14:52
【问题描述】:

我试图在 wxpython 面板中放置一个动画 gif,但显然我的 wxpython 版本中没有 animarion 或 adv 包:

In [1]: import wx
In [2]: wx.version()
Out[2]: '4.0.1 gtk3 (phoenix)'

然后我尝试将 gif 用作wx.Bitmap,但它当然不会播放。我知道根据凤凰文档:

https://wxpython.org/Phoenix/docs/html/classic_vs_phoenix.html

gif 处理程序类丢失了,但我想知道是否有任何方法可以在 phoenix 中使用 gif(可能是线程?)。

【问题讨论】:

    标签: python-2.7 wxpython


    【解决方案1】:

    wx.adv 包含AnimationAnimationCtrl
    撕掉了demo的

    import wx
    from wx.adv import Animation, AnimationCtrl
    
    class TestPanel(wx.Frame):
        def __init__(self, parent):
            wx.Frame.__init__(self, parent, -1)
            sizer = wx.BoxSizer(wx.VERTICAL)
            anim = Animation('/home/rolf/loveyourjob5qj.gif')
            ctrl = AnimationCtrl(self, -1, anim)
            ctrl.Play()
            sizer.Add(ctrl)
            self.SetSizerAndFit(sizer)
            self.Show()
    
    if __name__ == '__main__':
        test=wx.App()
        TestPanel(None)
        test.MainLoop()
    

    【讨论】:

    • 我尝试使用你的代码,你知道我的内核为什么会崩溃吗?我尝试了不同的 Gif 文件,我的 Wxpython 版本是 4.0.4 msw (phoenix) wxWidgets 3.0.5,我使用 Python 3。
    • @K-Doe 根本没有。我在 Linux python 3.6.7 wx 4.0.4 gtk2 (phoenix) wxWidgets 3.0.5 上重新测试了这段代码。我还针对 wx 4.0.1 gtk3 对其进行了测试。两者都可以正常工作。你没有说你的内核是如何“崩溃”的
    • 感谢您的测试。可悲的是,我的 IDE 没有给我任何进一步的信息。如果我运行代码,我会看到它启动了,但没有出现任何窗口,大约 2 秒后它显示 Kernel died, restarting 不多。
    • @K-Doe 您是否考虑过它可能是您的环境?在命令行上运行它会发生什么?
    • 就是这样。我在两台电脑上测试过,都遇到了同样的问题。第三天,在家里,一切都很顺利。现在我知道它的环境了。谢谢!
    猜你喜欢
    • 2012-03-23
    • 2013-12-22
    • 2016-08-23
    • 2013-12-17
    • 1970-01-01
    • 2019-08-11
    • 1970-01-01
    • 2021-03-19
    • 1970-01-01
    相关资源
    最近更新 更多