【问题标题】:Remove grey box around GIFs in Python Kivy?在 Python Kivy 中删除 GIF 周围的灰色框?
【发布时间】:2021-05-31 13:16:31
【问题描述】:

我使用 Kivy 在 Python 中创建了一个应用程序,但是当我使用这个具有透明背景的 GIF 时,GIF 周围会出现一个灰色框。我不明白这是为什么?

这是灰色框(点是 gif):

有问题的 GIF:https://ibb.co/dMnxWVW

这是 GIF 的 Python 代码:

    def on_press(self):
       self.ids.mic_image.anim_loop = 0
       self.ids.mic_image.source = "Mic_Pressed.gif"

这是 GIF 的 .kv 代码:

Image:
    source: "Mic_Pressed.gif"
    opacity: 0
    anim_delay: 0
    size_hint: (0.6,0.6)
    pos_hint: {"center_x":0.5, "center_y": 0.2}


Image:
    id: mic_image
    source: "Mic_Static.gif"
    opacity: 1
    anim_delay: 0
    size_hint: (0.6,0.6)
    pos_hint: {"center_x":0.5, "center_y": 0.2}


Button:
    id: mic
    background_color: (1, 1, 1, 0)
    pos_hint: {"center_x":0.5, "y":0.09}
    size_hint: (0.2,0.19)
    on_press:
        root.on_press()

应用程序最初显示“Mic_Static.gif”(没有任何灰色框)。按下按钮(与 GIF 大小相同)时,会显示“Mic_Pressed.gif”,但周围有灰色框。

【问题讨论】:

    标签: ios image kivy gif


    【解决方案1】:

    我认为这是您的 gif 文件的问题。试试这个替换

    【讨论】:

    • 不幸的是,这似乎不起作用 - 还有其他想法吗?
    • 我想出了一个解决方案:我在网上使用了一个 gif maker 来防止 gif 帧的堆叠,现在它可以正常工作了。
    猜你喜欢
    • 2020-06-24
    • 1970-01-01
    • 1970-01-01
    • 2023-03-07
    • 2017-01-02
    • 1970-01-01
    • 2017-10-28
    • 2021-08-30
    • 1970-01-01
    相关资源
    最近更新 更多