Image 使用带有kivy按钮的图像,无效数据错误

Image 使用带有kivy按钮的图像,无效数据错误,image,button,kivy,Image,Button,Kivy,声明错误后,我获取的数据无效。这似乎类似于kivy文档中显示的如何使用图像作为按钮图片。。。但我显然有点不对劲 这是我的.kv文件,知道我为什么会收到这个问题吗 #:kivy 1.9.2 <YourWidget>: BoxLayout: size: root.size pos: root.pos orientation: 'vertical' spacing: 10 padding: 10 BoxLayout: or

声明错误后,我获取的数据无效。这似乎类似于kivy文档中显示的如何使用图像作为按钮图片。。。但我显然有点不对劲

这是我的.kv文件,知道我为什么会收到这个问题吗

 #:kivy 1.9.2
<YourWidget>:
BoxLayout:
    size: root.size
    pos: root.pos
    orientation: 'vertical'
    spacing: 10
    padding: 10

    BoxLayout:
        orientation: 'horizontal'
        spacing: 10
        padding: 10
        Button:
            id: btn1
            text: "Change Text"
            on_release: root.change_text()
            size_hint: 1, 1

        Button:
            id: btn2
            text: "Exit App"
            on_release: root.ExitApp()
            size_hint: 1, 1

        Label:
            id: lbl1
            font_size: 15
            text:root.random_number
            size_hint: 1, 1
        Label:
            id: lblTemp
            font_size: 15
            text:root.tempProbe1
            size_hint: 1, 1
    BoxLayout:
        orientation: 'horizontal'
        spacing: 10
        padding: 10
        Label:
            id: lblErrors
            text: root.currentError
            font_size: 15
            size_hint: 1, 1

        Button:
            id: btn4
            text: root.button4status
    background_down: 'led1.png'
    on_press: root.button4pressed()
            size_hint: 1, 1

        Label:
            id: lbl2
            font_size: 15
            text:root.button4status
            size_hint: 1, 1

        Label:
            id: lbl3
            font_size: 15
            text: "Unused Currently"
            size_hint: 1, 1
#:kivy 1.9.2
:
盒子布局:
大小:root.size
pos:root.pos
方向:“垂直”
间距:10
填充:10
盒子布局:
方向:“水平”
间距:10
填充:10
按钮:
id:btn1
文本:“更改文本”
发布时:root.change\u text()
大小提示:1,1
按钮:
id:btn2
文本:“退出应用程序”
发布时:root.ExitApp()
大小提示:1,1
标签:
id:lbl1
字体大小:15
文本:root.random\u编号
大小提示:1,1
标签:
id:lblTemp
字体大小:15
文本:root.tempProbe1
大小提示:1,1
盒子布局:
方向:“水平”
间距:10
填充:10
标签:
身份证号码:lblErrors
文本:root.currentError
字体大小:15
大小提示:1,1
按钮:
id:btn4
文本:root.button4status
背景:“led1.png”
按下按钮:root.button4pressed()
大小提示:1,1
标签:
id:lbl2
字体大小:15
文本:root.button4status
大小提示:1,1
标签:
id:lbl3
字体大小:15
文本:“当前未使用”
大小提示:1,1

您的缩进似乎不正确,至少在发布的代码中是的,它不在我的树莓皮上。反正也不像那里的节目,我只是注意到了。在我的文件中它似乎是正确的,但一旦我删除了缩进,并通过使用完美数量的空格使其更加精确,程序就开始工作了。