Search code examples
pythonpython-3.xkivykivy-language

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


I am trying to use the Window Manager in kivy but I keep get the following error

[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

Here is the .kv file

WindowManager:
    MainWindow:
    FtoC:
    CtoF:




<MainWindow>:
    name: "main"

        

<FtoC>:

    name: "fTOc"
    

            

<CtoF>:
    name: "cTOf"

The WindowManager area is giving me the following error:

Kivy parser exception: 'NoneType' object is not subscriptable

I would be very thankfull is someone found out what is wrong with this code because I can not find it. Its probably something simple that I didn't see.

Edit:

hear is a is code that is NOT giving the error:

WindowManager:
    MainWindow:
    FtoC:
    CtoF:

<MainWindow>:
    name: "main"
    

    BoxLayout:
        
    

hear is code that IS giving the error:

 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: 

Is can see from this that when I add content to the BoxLayout I get the error. Though I still do not know why this is causing the error or how to fix it. I hope this helps people solve this problem.


Solution

  • There was an indentation error in my code. I would like to thank @Inclement for his help.