Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import random
- import console
- def get_answers(filename) :
- '''read and parse the answer file'''
- ret = []
- filehandle = open(filename,'r')
- for line in filehandle.readlines() :
- if line.strip().startswith('#') :
- continue
- if '--' in line :
- line, otherstuff = line.split('--',1)
- line = line.strip()
- if line != '' :
- ret.append(line)
- filehandle.close()
- return ret
- answers = get_answers('Eight_Ball_Answers.text')
- import ui
- def button_tapped(sender):
- sender.title = random.choice(answers)
- view = ui.View()
- view.name = 'Magic Eight Ball'
- view.background_color = 'black'
- button = ui.Button(title='To Begin Magic Eight Ball, Tap Me!')
- button.center = (view.width * 0.5, view.height * 0.5)
- button.flex = 'LRTB'
- button.action = button_tapped
- view.add_subview(button)
- view.present('sheet')
- #you also need this in another file, that is named Eight_Ball_Answers.text
- # positives
- It is certain
- It is decidedly so
- Without a doubt
- Yes definitely
- You may rely on it
- As I see it, yes
- Most likely
- Outlook good
- Yes
- Signs point to yes
- #ask agains
- Reply hazy try again
- Ask again later
- Better not tell you now
- Cannot predict now
- Concentrate and ask again later
- # negitives
- Don't count on it
- My reply is no
- My sources say no
- Outlook not so good
- Very doubtful
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement