Created
May 24, 2014 10:38
-
-
Save blackmann/8c033c6243561f1cb84e to your computer and use it in GitHub Desktop.
A simple log-in app in python4android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#some simple login app | |
from android import Android | |
import time | |
import random | |
a = Android() | |
p=0 | |
a.dialogCreateHorizontalProgress("Loading App") | |
a.dialogShow() | |
while p <= 100: | |
prog_bar= random.randrange(1,11) | |
a.dialogSetCurrentProgress(p) | |
time.sleep(0.2) | |
p+=prog_bar | |
print "Done loading!" | |
a.dialogDismiss() | |
print '-'*17 | |
a.dialogCreateAlert("Lex", "Please Sign in") | |
a.dialogShow() | |
time.sleep(1.8) | |
a.dialogDismiss() | |
#sub challenge | |
data = {"lexis":"12345","degreat":"andex"} | |
tries = 3 | |
while tries >= 0: | |
if tries == 0: | |
print "--Bye bye--" | |
break | |
a.dialogCreateInput("Enter username","username") | |
a.dialogSetPositiveButtonText("OK") | |
a.dialogShow() | |
user=a.dialogGetResponse().result | |
username = user["value"] | |
a.dialogCreatePassword() | |
a.dialogSetPositiveButtonText("OK") | |
a.dialogShow() | |
passw = a.dialogGetResponse().result | |
password = passw["value"] | |
if data.has_key(username): | |
if password == data[username]: | |
a.dialogCreateAlert("Logged") | |
a.dialogShow() | |
time.sleep(2) | |
a.dialogDismiss() | |
tries = -1 | |
print "--Login success--" | |
else: | |
a.dialogueCreateAlert("Sorry! Try Again") | |
a.dialogShow() | |
time.sleep(2) | |
a.dialogDismiss() | |
tries-=1 | |
else: | |
a.dialogCreateAlert("Sorry! Try Again") | |
a.dialogShow() | |
time.sleep(2) | |
a.dialogDismiss() | |
tries -= 1 | |
#main challenge -- the media player | |
#quit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This program requires you to install sl4a(scripting layer for android) and py4a(python for android) on your android mobile. The users dictionary can be modified to read login credentials from a txt file.