Last active
August 29, 2015 14:06
-
-
Save driscollis/cd6e81fac21f33db1750 to your computer and use it in GitHub Desktop.
kv_login with just python
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
from kivy.app import App | |
from kivy.uix.boxlayout import BoxLayout | |
from kivy.uix.button import Button | |
from kivy.uix.label import Label | |
from kivy.uix.textinput import TextInput | |
class TutorialApp(App): | |
def build(self): | |
main_layout = BoxLayout(orientation="vertical") | |
user_layout = BoxLayout(orientation="horizontal", | |
padding=15, | |
spacing=5) | |
password_layout = BoxLayout(orientation="horizontal", | |
padding=15, | |
spacing=5) | |
spacer = BoxLayout(orientation="vertical") | |
# layout the username widgets | |
username_lbl = Label(text="Username:") | |
user_layout.add_widget(username_lbl) | |
self.username_txt = TextInput(font_size=80, | |
size_hint_y=None, | |
height=110) | |
user_layout.add_widget(self.username_txt) | |
main_layout.add_widget(user_layout) | |
# layout the password widgets | |
password_lbl = Label(text="Password:") | |
password_layout.add_widget(password_lbl) | |
self.password_txt = TextInput(font_size=80, | |
size_hint_y=None, | |
height=110, | |
password=True) | |
password_layout.add_widget(self.password_txt) | |
main_layout.add_widget(password_layout) | |
# add login button | |
login_button = Button(text="Login", | |
size_hint_x=None, | |
width=300, | |
pos_hint={'center_x':0.5}) | |
login_button.bind(on_press=self.on_login) | |
main_layout.add_widget(login_button) | |
main_layout.add_widget(spacer) | |
return main_layout | |
#---------------------------------------------------------------------- | |
def on_login(self, button): | |
"""""" | |
username = self.username_txt.text | |
password = self.password_txt.text | |
if username == "admin" and password == "admin": | |
print "You're logged in and you have a really bad password!" | |
else: | |
print "Username or password is not correct!" | |
if __name__ == "__main__": | |
TutorialApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment