-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoginScreen.py
56 lines (46 loc) · 1.66 KB
/
LoginScreen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from kivy.uix.screenmanager import Screen
from kivy.properties import StringProperty
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from kivy.uix.image import Image
import time
# Declare both screens
class LoginScreen(Screen):
message = StringProperty()
def __init__(self, **kwargs):
super(LoginScreen, self).__init__(**kwargs)
# Draw widgets
layout = FloatLayout()
fond = Image(source='img/cac.jpg')
glayout = GridLayout(size_hint=(0.5,0.25),
pos_hint={'x': .25, 'y': .25},
rows=2,
cols=2,
padding=10,
spacing=10)
label1 = Label(text="Nom : ")
self.f_username = TextInput()
self.label = Label(text=self.message)
btn = Button(text="Connexion", on_press=self.submit)
glayout.add_widget(label1)
glayout.add_widget(self.f_username)
glayout.add_widget(self.label)
glayout.add_widget(btn)
layout.add_widget(fond)
layout.add_widget(glayout)
self.add_widget(layout)
def callback_ping(self, success):
self.label.text = 'Ping successful'
def callback_login(self, success, msg=''):
if success:
self.manager.current = 'lobby'
else:
print('Fail')
self.label.text = msg
def on_enter(self):
pass
def submit(self, e):
self.manager.gm.login(self.callback_login, self.f_username.text)