我正在尝试为python设置Visual Studio代码,除了Kivy之外,其他所有功能都很好。
我有简单的代码
import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from kivy.uix.widget import Widget
class MyGrid(Widget):
pass
class MyApp(App):
def build(self):
return MyGrid()
if __name__ == "__main__":
MyApp().run()
和简单的kivy文件
#:kivy
<MyGrid>:
GridLayout:
cols:1
size: root.width, root.height
GridLayout:
cols:2
Label:
text: "Name: "
TextInput:
multinline:False
Label:
text: "Email: "
TextInput:
multiline:False
Button:
text:"Submit"
当我尝试运行python文件时,我得到了
kivy.lang.parser.ParserException:解析器:文件“ c:\ Users \Paweł\ Documents \ projects vscode \ WeatherProject \ my.kv”,第1行: 1:#:基维 2 :: 3:GridLayout: 未知指令
Google根本没有帮助。请告诉我该怎么办。
答案 0 :(得分:1)
也许它应该修复它!
MyGrid:
<MyGrid>:
GridLayout:
cols:1
size: root.width, root.height
GridLayout:
cols:2
Label:
text: "Name: "
TextInput:
multinline:False
Label:
text: "Email: "
TextInput:
multiline:False
Button:
text:"Submit"