Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何添加透明背景的gif_Python_Python 3.x_Transparency_Tk - Fatal编程技术网

Python 如何添加透明背景的gif

Python 如何添加透明背景的gif,python,python-3.x,transparency,tk,Python,Python 3.x,Transparency,Tk,我试图将图像放入窗口中,然后移动它或其他东西,但我无法添加它,因为它显示时背景为白色:( 我找到了这个命令,但当我这样做时,它会生成一个单独的窗口,我想用画布或标签来完成 root = tk.Tk() root.image = tk.PhotoImage(file='startup.gif') label = tk.Label(root, image=root.image, bg='white') root.overrideredirect(True) root.geometry("

我试图将图像放入窗口中,然后移动它或其他东西,但我无法添加它,因为它显示时背景为白色:(

我找到了这个命令,但当我这样做时,它会生成一个单独的窗口,我想用画布或标签来完成

root = tk.Tk()

root.image = tk.PhotoImage(file='startup.gif')
label = tk.Label(root, image=root.image, bg='white')
root.overrideredirect(True)
root.geometry("+250+250")
root.lift()
root.wm_attributes("-topmost", True)
root.wm_attributes("-disabled", True)
root.wm_attributes("-transparentcolor", "white")
label.pack()
label.mainloop()

你确定你的图像有一个透明的背景吗?还有,什么是
root
?@DYZ我已经试着把它只放在窗口上了,但它看起来是一样的:(还有,为什么这么粗鲁?我正在学习这是否回答了你的问题?