Kivy: Unknown class error code

后端 未结 2 847
迷失自我
迷失自我 2021-02-10 16:17

This is the main.py

from kivy.app import App
    
    
class WeatherApp(App):
    pass
    
    
if __name__ == \'__main__\         


        
2条回答
  •  长发绾君心
    2021-02-10 16:36

    I solve this with:

    main.py

    from kivy.app import App 
    from kivy.uix.recycleview import RecycleView
    
    class RV(RecycleView):
        def __init__(self, **kwargs):
            super(RV, self).__init__(**kwargs)
            self.data = [{'text': str(values)} for values in ["Palo Alto, MX", "Palo Alto, US"]]
    
    
    class WeatherAPP(App):
        pass
    
    if __name__ == '__main__':
        WeatherAPP().run()
    

    weather.kv

    #:kivy 1.10
    AddLocationForm:
    
    :
        orientation: 'vertical'
        BoxLayout:
            TextInput:
            Button:
                text: "Search"
            Button:
                text: "Current Location"
        RV:
            viewclass: 'Label'
            RecycleBoxLayout:
                default_size: None, dp(56)
                default_size_hint: 1, None
                size_hint_y: None
                height: self.minimum_height
                orientation: 'vertical'
    

提交回复
热议问题