首先,我对kivy全新,所以我有点挣扎.
我正试图在一个kivy窗口中显示一个numpy数组.到目前为止,我发现这应该使用Texture Class(http://kivy.org/docs/api-kivy.graphics.texture.html).
由于我的numpy数组不时更改,我正在尝试将以下代码调整到我的应用程序.
# create a 64x64 texture, defaults to rgb / ubyte
texture = Texture.create(size=(64, 64))
# create 64x64 rgb tab, and fill with values from 0 to 255
# we'll have a gradient from black to white
size = 64 * 64 * 3
buf = [int(x * 255 / size) for x in range(size)]
# then, convert the array to a ubyte string
buf = b''.join(map(chr, buf))
# then blit the buffer
texture.blit_buffer(buf, colorfmt='rgb', …Run Code Online (Sandbox Code Playgroud)