Python:【kivy】这种硬编码是否有必要???

在尝试运行Kivy的app_suite.py示例时,由于将<Prebuilt>误写为<PreBuilt>导致解析错误。错误信息指出在第3行存在过多的缩进级别,从而引发了ParserException。问题定位在kv语言的布局定义中。
摘要由CSDN通过智能技术生成

在测试执行kivy的示例:app_suite.py的时候,误把<Prebuilt>写成<PreBuilt>然后就报错如下:

 
[INFO   ] [Logger      ] Record log in C:\Users\asus\.kivy\logs\kivy_23-07-22_72.txt
[INFO   ] [deps        ] Successfully imported "kivy_deps.gstreamer" 0.3.3
[INFO   ] [deps        ] Successfully imported "kivy_deps.angle" 0.3.3
[INFO   ] [deps        ] Successfully imported "kivy_deps.glew" 0.3.1
[INFO   ] [deps        ] Successfully imported "kivy_deps.sdl2" 0.6.0
[INFO   ] [Kivy        ] v2.2.1
[INFO   ] [Kivy        ] Installed at "D:\code\luncher\python3910\lib\site-packages\kivy\__init__.py"
[INFO   ] [Python      ] v3.9.10 (tags/v3.9.10:f2f3f53, Jan 17 2022, 15:14:21) [MSC v.1929 64 bit (AMD64)]
[INFO   ] [Python      ] Interpreter at "D:\code\luncher\python3910\python.exe"
[INFO   ] [Logger      ] Purge log fired. Processing...
[INFO   ] [Logger      ] Purge finished!
[INFO   ] [Factory     ] 190 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
 Traceback (most recent call last):
   File "D:\code2\vegetabledog\kivy_app\app_suite\app_suite.py", line 73, in <module>
     class TestPreBuildApp(App):
   File "D:\code2\vegetabledog\kivy_app\app_suite\app_suite.py", line 76, in TestPreBuildApp
     Builder.load_string(kv)
   File "D:\code\luncher\python3910\lib\site-packages\kivy\lang\builder.py", line 372, in load_string
     parser = Parser(content=string, filename=fn)
   File "D:\code\luncher\python3910\lib\site-packages\kivy\lang\parser.py", line 483, in __init__
     self.parse(content)
   File "D:\code\luncher\python3910\lib\site-packages\kivy\lang\parser.py", line 593, in parse
     objects, remaining_lines = self.parse_level(0, lines)
   File "D:\code\luncher\python3910\lib\site-packages\kivy\lang\parser.py", line 696, in parse_level
     _objects, _lines = self.parse_level(
   File "D:\code\luncher\python3910\lib\site-packages\kivy\lang\parser.py", line 766, in parse_level
     raise ParserException(self, ln,
 kivy.lang.parser.ParserException: Parser: File "<inline>", line 3:
 ...
       1:<PreBuilt>
       2: Button:
 >>    3:    text:'hello from TestPrebuiltApp'
 ...
 Invalid indentation (too many levels)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

千码君2016

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值