Skip to content

Instantly share code, notes, and snippets.

@Michcioperz
Created May 20, 2015 19:12
Show Gist options
  • Select an option

  • Save Michcioperz/f309877053e6f66d3dff to your computer and use it in GitHub Desktop.

Select an option

Save Michcioperz/f309877053e6f66d3dff to your computer and use it in GitHub Desktop.
Random flashcard app for SL4A Python
# encoding: utf-8
import android, random, time
q = [
["el quiosco","duży kiosk"],
["el hotel","hotel"],
["la plaza","plac"],
["el banco","bank"],
["la biblioteca","biblioteka"],
["la piscina","basen"],
["el ayuntamiento","ratusz"],
["la catedral","katedra"],
["la oficina de turismo", "biuro turystyczne"],
["el colegio","szkoła"],
["la farmacia","apteka"],
["el centro de salud","przychodnia"],
]
droid = android.Android()
while True:
x = random.choice(q)
random.shuffle(x)
r = droid.dialogGetInput("Traduz", x[0]).result
if r is None:
break
if r == x[1]:
droid.makeToast("Yes!")
droid.vibrate(400)
else:
droid.dialogCreateAlert(str(r==x[1]), "\n".join(["%s - question" % x[0],"%s - correct" % x[1],"%s - yours" % r]))
droid.dialogSetNegativeButtonText("Español-senpai, notice me...")
droid.vibrate(100)
droid.dialogShow()
droid.dialogGetResponse()
droid.dialogDismiss()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment