问题
我可以在 kivy 中使用 Image() 模块加载图片.但由于某种原因,我无法将 .tif 文件加载到 kivy 中.当图像源是 '..picslugia.png' 时,图像加载得非常好.但是如果源是 '..picssnorlax.tif',我只会得到那个白框和错误:
problem
I am able to load pictures with the Image() module in kivy. But for some reason, I can't load .tif files into kivy. When the image source is '..picslugia.png', the image loads perfectly fine. But if the source is '..picssnorlax.tif', I just get that white box and the error:
[WARNING] [Image ] Unable to load image <C:Userspathpicssnorlax.tif>
[ERROR ] [Image ] Error loading texture ..picssnorlax.tif
代码
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.clock import Clock
from kivy.uix.image import Image
class ContainerBox(BoxLayout):
def __init__(self, **kwargs):
super(ContainerBox, self).__init__(**kwargs)
self.orientation = 'vertical'
#self.picture = Image(allow_stretch=True, source='..picslugia.png')
self.picture = Image(allow_stretch=True, source='..picssnorlax.tif')
Clock.schedule_once(lambda dt: self.add_widget(self.picture), timeout=0.1)
class SimpleImage(App):
def build(self):
return ContainerBox()
if __name__ == '__main__':
SimpleImage().run()
技术细节
我的问题
是我做错了什么,还是 Kivy 不支持 TIFF 格式?
my question to you
Am I doing something wrong, or does Kivy just not support TIFF format?
你需要创建一个正确的安装
我使用 anaconda 来安装 kivy,但我对正确安装依赖项并不是很彻底.所以我不得不创建一个全新的虚拟 python 安装.
You need to create a proper installation
I used anaconda to install kivy and I wasn't very thorough with installing the dependencies properly. So I had to create a fresh virtual python installation.
注意:这适用于 python 3.5 或更高版本.另外,我会让你明确说明什么 python 安装将创建这个环境.据我所知,没有充分的理由这样做.
Note: This is for python version 3.5 or higher. Also I am going to have you explicitly state what python installation is going to be creating this environment. To my knowledge, there's no good reason to do this.
Windows
python导入系统、操作系统os.path.dirname(sys.executable)C:UsersHAppDataLocalProgramsPythonPython36python -m venv C:UsersHvenvsenv1python -m venv C:UsersHvenvsenv1C:UsersHvenvsenv1Scriptsactivatepython -m pip install docutils pygments pypiwin32 kivy_deps.sdl2==0.1.22 kivy_deps.glew==0.1.12python -m pip install kivy==1.11.1这篇关于无法在 Kivy 中查看 tiff 图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何制作一个在 Python 中提供角色的不和谐机器人How to make a discord bot that gives roles in Python?(如何制作一个在 Python 中提供角色的不和谐机器人?)
Discord 机器人没有响应命令Discord bot isn#39;t responding to commands(Discord 机器人没有响应命令)
你能得到“关于我"吗?Discord 机器人的功能?Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“关于我吗?Discord 机器人的功能?(不和谐.py))
message.channel.id Discord PYmessage.channel.id Discord PY(message.channel.id Discord PY)
如何在 heroku 上托管我的 discord.py 机器人?How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 机器人?)
discord.py - 自动更改角色颜色discord.py - Automaticaly Change an Role Color(discord.py - 自动更改角色颜色)