我正在从Dusty Philips的书“在Kivy中创建应用程序”中做练习。我写的代码与书中的示例相同,但是不起作用。我得到错误: 引发FactoryException('未知类<%s>'%名称) kivy.factory.FactoryException:未知类ListView
我是Kivy的初学者,所以我自己无法解决。可能这很容易。我的代码.py和.kv如下:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
class AddLocationForm(BoxLayout):
def search_location(self):
print("Explicit is better than implicit.")
class WeatherApp(App):
pass
if __name__ == '__main__':
WeatherApp().run()
常用文件:
AddLocationForm:
<AddLocationForm>:
orientation: "vertical"
BoxLayout:
height: "40dp"
size_hint_y: None
TextInput:
size_hint_x: 1
Button:
text: "Search"
size_hint_x: 0.5
on_press: root.search_location()
Button:
text: "Current Location"
size_hint_x: 0.5
ListView:
item_strings: ["Palo Alto, MX", "Palo Alto, US"]