删除 Python Kivy 中 GIF 周围的灰色框?
Remove grey box around GIFs in Python Kivy?
我在 Python 中使用 Kivy 创建了一个应用程序,但是当我使用这个具有透明背景的 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”,但周围有灰色框。
我认为这是您的 gif 文件的问题。试试这个替换
我在 Python 中使用 Kivy 创建了一个应用程序,但是当我使用这个具有透明背景的 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”,但周围有灰色框。
我认为这是您的 gif 文件的问题。试试这个替换