Created
April 25, 2017 05:22
-
-
Save freakboy3742/0ad2294f195b1a0dd4206383ac2ed67d to your computer and use it in GitHub Desktop.
Password example
This file contains hidden or 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
import toga | |
class Login(toga.App): | |
def validate_user(self, widget): | |
if self.username.value == self.password.value: | |
self.main_window.info_dialog("Login", "Welcome to the show!") | |
else: | |
self.main_window.error_dialog("Error", "Go away, intruder!") | |
def startup(self): | |
self.main_window = toga.MainWindow(self.name) | |
self.main_window.app = self | |
un_label = toga.Label("Username") | |
self.username = toga.TextInput() | |
pw_label = toga.Label("Password") | |
self.password = toga.PasswordInput() | |
button = toga.Button("Login", on_press=self.validate_user) | |
box = toga.Box() | |
un_box = toga.Box() | |
pw_box = toga.Box() | |
un_box.add(un_label) | |
un_box.add(self.username) | |
pw_box.add(pw_label) | |
pw_box.add(self.password) | |
pw_box.add(button) | |
box.add(un_box) | |
box.add(pw_box) | |
self.username.style.set(width=100) | |
un_label.style.set(width=100) | |
self.password.style.set(width=100) | |
pw_label.style.set(width=100) | |
button.style.set(width=100) | |
un_box.style.set(padding=5, flex_direction='row') | |
pw_box.style.set(padding=5, flex_direction='row') | |
box.style.set(padding=5, flex_direction='column') | |
self.main_window.content = box | |
self.main_window.show() | |
def main(): | |
return Login('Login', 'org.pybee.login') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This doesn't run for me with
python -m login