Question

In: Computer Science

Using Python and Kivy to create a App to ask users 5 questions with Yes or...

Using Python and Kivy to create a App to ask users 5 questions with Yes or No button.
1. Are you older than 14?
2. Did you pass 8th or 9th Grade?
3. Are you ready gor highschool?
4. Do you have 4 more years to complete highschool?
5. Are you homeschool?

If the users click Yes for 3 questions or more than you should get a results page saying this users is in highschool
or else the user is not in highschool. and with pop up a list of highschool (Make up names).
And if they is in highschool give them a tip of being a student and if not give them tip before going to highschool.

Solutions

Expert Solution

import kivy

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.gridlayout import GridLayout
from kivy.uix.popup import Popup
from kivy.properties import StringProperty

Builder.load_string('''
<ConfirmPopup>:
cols:1
   Label:
       text: root.text
   GridLayout:
       cols: 2
       size_hint_y: None
       height: '44sp'
       Button:
           text: 'Yes'
           on_release: root.dispatch('on_answer','yes')
       Button:
           text: 'No'
           on_release: root.dispatch('on_answer', 'no')
cols:3
   Label:
       text: root.text
   GridLayout:
       cols: 4
       size_hint_y: None
       height: '44sp'
       Button:
           text: 'Yes'
           on_release: root.dispatch('on_answer','yes')
       Button:
           text: 'No'
           on_release: root.dispatch('on_answer', 'no')
cols:5
   Label:
       text: root.text
   GridLayout:
       cols: 6
       size_hint_y: None
       height: '44sp'
       Button:
           text: 'Yes'
           on_release: root.dispatch('on_answer','yes')
       Button:
           text: 'No'
           on_release: root.dispatch('on_answer', 'no')
cols:7
   Label:
       text: root.text
   GridLayout:
       cols: 8
       size_hint_y: None
       height: '44sp'
       Button:
           text: 'Yes'
           on_release: root.dispatch('on_answer','yes')
       Button:
           text: 'No'
           on_release: root.dispatch('on_answer', 'no')
cols:9
   Label:
       text: root.text
   GridLayout:
       cols: 10
       size_hint_y: None
       height: '44sp'
       Button:
           text: 'Yes'
           on_release: root.dispatch('on_answer','yes')
       Button:
           text: 'No'
           on_release: root.dispatch('on_answer', 'no')
''')

class ConfirmPopup(GridLayout):
   text = StringProperty()
  
   def __init__(self,**kwargs):
       self.register_event_type('on_answer')
       super(ConfirmPopup,self).__init__(**kwargs)
      
   def on_answer(self, *args):
       pass  
  

class PopupTest(App):
   def build(self):
       content = ConfirmPopup(text='1.Are you older than 14?')
       content.bind(on_answer=self._on_answer)
               self.popup = Popup(title="Answer Question",
                           content=content,
                           size_hint=(None, None),
                           size=(480,400),
                           auto_dismiss= False)
       self.popup.open()
   def build(self):
      
       content = ConfirmPopup(text='2.Did you pass 8th or 9th Grade?')
       content.bind(on_answer=self._on_answer)
      
       self.popup = Popup(title="Answer Question",
                           content=content,
                           size_hint=(None, None),
                           size=(480,400),
                           auto_dismiss= False)
       self.popup.open()
   def build(self):
      
       content = ConfirmPopup(text='3.Are you read gor highschool?')
       content.bind(on_answer=self._on_answer)
      
       self.popup = Popup(title="Answer Question",
                           content=content,
                           size_hint=(None, None),
                           size=(480,400),
                           auto_dismiss= False)
       self.popup.open()
   def build(self):
      
       content = ConfirmPopup(text='4.Do you have 4 more years to complete highschool?')
       content.bind(on_answer=self._on_answer)
       self.popup = Popup(title="Answer Question",
                           content=content,
                           size_hint=(None, None),
                           size=(480,400),
                           auto_dismiss= False)
       self.popup.open()
   def build(self):
       content = ConfirmPopup(text='5.Are you homeschool?')
       content.bind(on_answer=self._on_answer)
       self.popup = Popup(title="Answer Question",
                           content=content,
                           size_hint=(None, None),
                           size=(480,400),
                           auto_dismiss= False)
       self.popup.open()
      
   def _on_answer(self, instance, answer):
       if('on_answer','yes'>=3)
       print "This user is in highschool " repr(answer)
       self.popup=Popup(Be the best of yourself)
       else
       print "The user is not in highschool", repr(answer)
       self.popup=Popup(Slow & Study wins the race)
      
if __name__ == '__main__':
   PopupTest().run()

Thank you!!! & Don't forget to smile:)


Related Solutions

Create a simple python app that allows the user to create a roster of students and...
Create a simple python app that allows the user to create a roster of students and their grade on CUS-1166. Moreover the app needs to calculate the average grade of students added to the roster. 1-To begin with, create a new file n the same working folder as part A (i.e. cus1166_lab1) and name it app.py. Moreover, create a subfolder and name it mymodules. 2-Within mymodules create the files __init__.py , models.py , math_utils.py . 3-In the models.py file define...
Create a program that ask to input two users and the result will vary on their...
Create a program that ask to input two users and the result will vary on their name with similar digits. In a game of F.L.A.M.E.S , it will count and repeat depends on their name that has a similar digit. For an Example (JOE RIZAL) and (JACKLYN BRACKEN) - JOE RIZAL has - 5 similar digits , while JACKLYN BRACKEN has 6 similar digits so a total of 11. F - Friends - 1,7 L - Lover - 2,8 A...
Create a program (Python) YourFirstnameLastnameA06b.py to ask the user to create a password: The user will...
Create a program (Python) YourFirstnameLastnameA06b.py to ask the user to create a password: The user will first enter a password, then enters the same password again; If the second input is the same as first one, the user successfully creates the password. Print “Well done.”; Otherwise, the user will be directed to repeat the whole process (go to step 1.)
create a python program that ask for a name and birth year separated by a comma....
create a python program that ask for a name and birth year separated by a comma. the program should keep prompting until the user inputs 'quit'. print the dictionary containing the key value pair name:year in the same order they were inputted. print the name and birth year on a single line for each of the entries. finally print the dictionary with the key value paris swapped and sorted by birth year. from youngest to oldeest.
Using Python : Create a 4×5 4 × 5 array ? X with random value. Print...
Using Python : Create a 4×5 4 × 5 array ? X with random value. Print out ? X , as well as the largest value of each column.
Using Python, Write an app for patients such as patients requiring surgery and patients who are...
Using Python, Write an app for patients such as patients requiring surgery and patients who are pregnant and relevant functionalities. Note : It's not a complex app. It is for my fundamental 2 class to understand the inheritance concept. Simpler the better.
Create a Scorekeeper app in android studio by using java language - Layouts | Widgets Create...
Create a Scorekeeper app in android studio by using java language - Layouts | Widgets Create the layout for your score keeping app. The app should have: Two team names (TextViews) Two scores (TextViews) Buttons to increase/ decrease the scores An amount to change the score by (RadioButtons) You must have at least two score options The scores can be changed by anything you want American football: 1, 2, 3, 6 Basketball: 1, 2, 3 Freestyle wrestling: 1, 2, 3,...
USE PYTHON. Create a program that will ask a user to enter whole positive numbers. The...
USE PYTHON. Create a program that will ask a user to enter whole positive numbers. The program will use a while loop to let the program keep running. The user will be allowed to use the program as long as the quitVariable is equal to 'y' or 'Y'. When the user decides to quit playing, say "Thanks for playing!". The program will use a for loop to test if the number are even or odd. If even print "number is...
Create a web page using PHP that allows the users to create an account (a username...
Create a web page using PHP that allows the users to create an account (a username and a password). There should be a login page that allows users to create an account by entering their preferred username and password. The same page should also let users login if they already have an account. If a user is logged in successfully , they should be able to enter a comment and also read the comments entered by others previously.
Should taxpayer dollars be spent to rehabilitate drug users? If yes, why yes? If no, why...
Should taxpayer dollars be spent to rehabilitate drug users? If yes, why yes? If no, why no?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT