python 中的 .kv 文件出错。 (可能与屏幕管理器有关。我不确定)

Error in .kv file in python. (May have to do with screen manager. I am not sure)

我正在尝试在 kivy 中使用 Window Manager 但我一直收到以下错误

[INFO   ] [Logger      ] Record log in C:\Users\Gavin\.kivy\logs\kivy_21-06-03_22.txt
[INFO   ] [deps        ] Successfully imported "kivy_deps.gstreamer" 0.3.2
[INFO   ] [deps        ] Successfully imported "kivy_deps.angle" 0.3.0
[INFO   ] [deps        ] Successfully imported "kivy_deps.glew" 0.3.0
[INFO   ] [deps        ] Successfully imported "kivy_deps.sdl2" 0.3.1
[INFO   ] [Kivy        ] v2.0.0
[INFO   ] [Kivy        ] Installed at "C:\Users\Gavin\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\__init__.py"
[INFO   ] [Python      ] v3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)]
[INFO   ] [Python      ] Interpreter at "C:\Users\Gavin\AppData\Local\Programs\Python\Python39\python.exe"
[INFO   ] [Factory     ] 186 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [GL          ] Using the "OpenGL" graphics system
[INFO   ] [GL          ] GLEW initialization succeeded
[INFO   ] [GL          ] Backend used <glew>
[INFO   ] [GL          ] OpenGL version <b'4.0.0 - Build 10.18.10.5069'>
[INFO   ] [GL          ] OpenGL vendor <b'Intel'>
[INFO   ] [GL          ] OpenGL renderer <b'Intel(R) HD Graphics 4000'>
[INFO   ] [GL          ] OpenGL parsed version: 4, 0
[INFO   ] [GL          ] Shading version <b'4.00 - Build 10.18.10.5069'>
[INFO   ] [GL          ] Texture max size <16384>
[INFO   ] [GL          ] Texture max units <16>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
 Traceback (most recent call last):
   File "c:\Users\Gavin\Documents\GitHub\Mobile Temperture Convertor\Mobile-Temperature-Convertor\main.py", line 15, in <module>
     kv = Builder.load_file("My.kv")
   File "C:\Users\Gavin\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\lang\builder.py", line 306, in load_file
     return self.load_string(data, **kwargs)
   File "C:\Users\Gavin\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\lang\builder.py", line 373, in load_string
     parser = Parser(content=string, filename=fn)
   File "C:\Users\Gavin\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\lang\parser.py", line 402, in __init__
     self.parse(content)
   File "C:\Users\Gavin\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\lang\parser.py", line 511, in parse
     objects, remaining_lines = self.parse_level(0, lines)
   File "C:\Users\Gavin\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\lang\parser.py", line 614, in parse_level
     _objects, _lines = self.parse_level(
   File "C:\Users\Gavin\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\lang\parser.py", line 614, in parse_level
     _objects, _lines = self.parse_level(
   File "C:\Users\Gavin\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\lang\parser.py", line 674, in parse_level
     if current_property[:3] == 'on_':
 TypeError: 'NoneType' object is not subscriptable

这是 .kv 文件

WindowManager:
    MainWindow:
    FtoC:
    CtoF:




<MainWindow>:
    name: "main"

        

<FtoC>:

    name: "fTOc"
    

            

<CtoF>:
    name: "cTOf"

WindowManager 区域出现以下错误:

Kivy parser exception: 'NoneType' object is not subscriptable

如果有人发现这段代码有什么问题,我将非常感激,因为我找不到它。它可能很简单,我没有看到。

编辑:

听到的是一个没有给出错误的代码:

WindowManager:
    MainWindow:
    FtoC:
    CtoF:

<MainWindow>:
    name: "main"
    

    BoxLayout:
        
    

听到的是给出错误的代码:

 WindowManager:
        MainWindow:
        FtoC:
        CtoF:
        
    <MainWindow>:
        name: "main"
        
    
        BoxLayout:
            orientation: 'vertical'
            size: root.width , root.height
    
            Label:
                text: "Fahrenheit to Celsius"
                    font_size: 32
    
            Button:
                    text: "Fahrenheit to Celsius"
                    font_size: 32
                    on_release: 

从这里可以看出,当我向 BoxLayout 添加内容时出现错误。虽然我仍然不知道为什么这会导致错误或如何解决它。 我希望这可以帮助人们解决这个问题。

我的代码中存在缩进错误。感谢@Inclement的帮助。