I try to make an app that is generating random questions when i press the button "ask" but i am stuck at this error..
{ return self.randrange(a, b+1) TypeError: can only concatenate str (not "int") to str }
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
import random
class MyRoot(BoxLayout):
def __init__(self):
super(MyRoot, self).__init__()
def generate_question(self):
self.random_question.text = str(random.randint("Is a car a car?", "Is a color a color"))
class RandomQuestionApp(App):
def build(self):
return MyRoot()
randomApp = RandomQuestionApp()
RandomQuestionApp().run()
<MyRoot>:
random_question: random_question
BoxLayout:
orientation: "vertical"
Label:
text: "Random Question"
font_size: 30
color: 0, 0.62, 0.96
Label:
id: random_question
text: "_"
font_size: 30
Button:
text: "Ask"
font_size: 15
on_press: root.generate_question()
THANKS !!
Aucun commentaire:
Enregistrer un commentaire