如何使用Kivy的核心形象? [英] How To Use Kivy's Core Image?
问题描述
我有一个网格布局,并向其中添加了一些我想用于显示图片的CoreImage小部件.我选择不使用uix.image,因为CoreImage速度更快,并且我希望经常在几张图片之间交换.
I have a grid layout and am adding to it some CoreImage widgets that I want to use for displaying pictures. I chose not to use uix.image since CoreImage is faster and I want to swap between a few pictures often.
当我执行self.add_widget(CoreImage('Transparent.png'))时,我的程序将崩溃.
When I do self.add_widget(CoreImage('Transparent.png')) my program will crash.
Traceback (most recent call last):
File "/path/to/my/app.py", line 1030, in <module>
MyApp().run()
File "/usr/lib/python2.7/dist-packages/kivy/app.py", line 798, in run
root = self.build()
File "/path/to/my/app.py", line 702, in build
self.build_grid()
File "/path/to/my/app.py", line 696, in build_grid
self.grid.build_self()
File "/path/to/my/app.py", line 134, in build_self
self.add_widget(CoreImage('Transparent.png'))
File "/usr/lib/python2.7/dist-packages/kivy/uix/layout.py", line 80, in add_widget
size_hint=self._trigger_layout)
File "_event.pyx", line 436, in kivy._event.EventDispatcher.bind (kivy/_event.c:5429)
KeyError: 'size_hint'
我做错了什么?当我使用uix.image时,效果很好.
What am I doing wrong? This works fine when I used uix.image.
推荐答案
kivy.core.image.Image
(我想这是您的意思)不是小部件,您不能像这样使用它.使用kivy.uix.image.Image
.
kivy.core.image.Image
(I assume this is what you mean) is not a widget, you can't use it like this. Use kivy.uix.image.Image
.
这篇关于如何使用Kivy的核心形象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!