Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/278.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 3.3.2中添加透明的tkinter图像?_Python_Tkinter_Transparency_Gif_Python 3.3 - Fatal编程技术网

如何在Python 3.3.2中添加透明的tkinter图像?

如何在Python 3.3.2中添加透明的tkinter图像?,python,tkinter,transparency,gif,python-3.3,Python,Tkinter,Transparency,Gif,Python 3.3,如何在Python 3.3.2中添加透明的tkinter图像? 我试过使用.gif,但是透明部分变白了 例如: from tkinter import * Foo = PhotoImage(file=Bar) image = Label(root, image=Foo) image.pack() 它可以找到图像和所有东西,但是gif的所有透明部分都是白色的 (在Photoshop或任何其他图像查看/编辑程序中打开时,它们是透明的) 谢谢你的帮助!:D (Psst。但是,如果我尝试使用其他任何东

如何在Python 3.3.2中添加透明的tkinter图像? 我试过使用.gif,但是透明部分变白了

例如:

from tkinter import *
Foo = PhotoImage(file=Bar)
image = Label(root, image=Foo)
image.pack()
它可以找到图像和所有东西,但是gif的所有透明部分都是白色的

(在Photoshop或任何其他图像查看/编辑程序中打开时,它们是透明的)

谢谢你的帮助!:D

(Psst。但是,如果我尝试使用其他任何东西,它不必只是GIF;我会收到一个错误,说明它无法读取图像中的数据。)

[编辑] 下面是我尝试使用上述代码打开透明的.png文件时的回溯

  File "C:\Python33\lib\tkinter\__init__.py", line 3362, in __init__
    self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't recognize data in image file ".\Stuff\Foo.png"

为了得到一个提示,您可能应该查看并询问回溯是因为无效的文件格式。要使用png文件,必须使用PIL,如图所示。然而,我尝试了我上一次评论中的提示,并没有得到令人满意的结果/我在Python3.4.3中使用PIL,至少它可以处理非透明图像。你有没有在非透明图像中尝试过PIL?