简体   繁体   中英

Invalid property name kivy

py code:
 from kivy.app import App
from kivy.graphics import Color
import random as rand
from kivy.uix.textinput import TextInput
from kivy.uix.label import Label
from kivy.uix.widget import Widget
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
class Numberguessing(BoxLayout):
    def __init__(self, **kwargs):
        super(Numberguessing, self).__init__(**kwargs)
        # self.cols=2
        # layout = BoxLayout(orientation='vertical')
        self.rn = rand.randrange(100)
        getkv = Builder.load_file('kivy/numberguessingapp.kv')
class NumberguessingApp(App):

    def build(self):
        return Numberguessing()



if __name__ == '__main__':
    NumberguessingApp().run()

kv code

<NumberGuessing>:
    BoxLayout:
        Label:
            text="Enter a guess here"

goal: Make a number guessing app in which the computer thinks of a number and the user tries to guess it. If the guess is bigger than the number then it prints in a new label Guess is higher. If the guess is lower it will print the guess is smaller thant the number. If it is same it will print you got it.

py code:
 from kivy.app import App
from kivy.graphics import Color
import random as rand
from kivy.uix.textinput import TextInput
from kivy.uix.label import Label
from kivy.uix.widget import Widget
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
class Numberguessing(BoxLayout):
    def __init__(self, **kwargs):
        super(Numberguessing, self).__init__(**kwargs)
        # self.cols=2
        # layout = BoxLayout(orientation='vertical')
        self.rn = rand.randrange(100)
        getkv = Builder.load_file('kivy/numberguessingapp.kv')
class NumberguessingApp(App):

    def build(self):
        return Numberguessing()



if __name__ == '__main__':
    NumberguessingApp().run()

kv code

<NumberGuessing>:
    BoxLayout:
        Label:
            text="Enter a guess here"

goal: Make a number guessing app in which the computer thinks of a number and the user tries to guess it. If the guess is bigger than the number then it prints in a new label Guess is higher. If the guess is lower it will print the guess is smaller thant the number. If it is same it will print you got it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM