Login UI in kivy
up vote
-1
down vote
favorite
Hello i have an application in kivy which has username and password
when user enter admin admin it goes to python function and say granted now the problem is
whenever it goes to function and execute the function it would return 1 how do i compare that 1 in kivy file as i am not aware of this and searched a lot no luck
import kivy
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.gridlayout import GridLayout
from kivy.uix.popup import Popup
from kivy.uix.label import Label
from kivy.uix.button import Button
import time
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang.builder import Builder
kivy.require('1.10.1')
class Admin(GridLayout,Screen):
def valid(self,u,p):
if "admin" == "admin" and "admin" == "admin":
print('Access Granted !')
else:
print('Invalid User')
class UserPage(Screen):
pass
class ScreenManagement(ScreenManager):
pass
kv_file = Builder.load_file('Admin.kv')
class AdminApp(App):
def build(self):
return kv_file
r=AdminApp()
r.run()
ScreenManagement:
Admin:
UserPage:
<CustLabel@Label>:
font_size:20
<Custbutton@Button>:
font_size:20
<MyPopup@Popup>:
auto_dismiss: False
Button:
text: 'Close me!'
on_release: root.dismiss()
<Admin>:
name: "Admin"
id:check
d_username:entry_username
d_password:entry_password
rows:5
spacing:10
BoxLayout:
CustLabel:
text:'Enter UserName'
TextInput:
id:entry_username
multiline:False
cursor_color: 1, 0, 0, 1
hint_text: 'Username'
padding_x: [50,50]
BoxLayout:
CustLabel:
text:'Enter Password'
TextInput:
id:entry_password
hint_text: 'Password'
padding_x: [50,50]
password: True
multiline:False
BoxLayout:
Custbutton:
text:'Go'
on_press:check.valid(entry_username.text,entry_password.text)
# i want to exectute on_release: app.root.current = "userpage" when its true ?????????????
<UserPage>:
name: "userpage"
Button:
text: "back"
on_release: app.root.current = "Admin"
python kivy kivy-language
add a comment |
up vote
-1
down vote
favorite
Hello i have an application in kivy which has username and password
when user enter admin admin it goes to python function and say granted now the problem is
whenever it goes to function and execute the function it would return 1 how do i compare that 1 in kivy file as i am not aware of this and searched a lot no luck
import kivy
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.gridlayout import GridLayout
from kivy.uix.popup import Popup
from kivy.uix.label import Label
from kivy.uix.button import Button
import time
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang.builder import Builder
kivy.require('1.10.1')
class Admin(GridLayout,Screen):
def valid(self,u,p):
if "admin" == "admin" and "admin" == "admin":
print('Access Granted !')
else:
print('Invalid User')
class UserPage(Screen):
pass
class ScreenManagement(ScreenManager):
pass
kv_file = Builder.load_file('Admin.kv')
class AdminApp(App):
def build(self):
return kv_file
r=AdminApp()
r.run()
ScreenManagement:
Admin:
UserPage:
<CustLabel@Label>:
font_size:20
<Custbutton@Button>:
font_size:20
<MyPopup@Popup>:
auto_dismiss: False
Button:
text: 'Close me!'
on_release: root.dismiss()
<Admin>:
name: "Admin"
id:check
d_username:entry_username
d_password:entry_password
rows:5
spacing:10
BoxLayout:
CustLabel:
text:'Enter UserName'
TextInput:
id:entry_username
multiline:False
cursor_color: 1, 0, 0, 1
hint_text: 'Username'
padding_x: [50,50]
BoxLayout:
CustLabel:
text:'Enter Password'
TextInput:
id:entry_password
hint_text: 'Password'
padding_x: [50,50]
password: True
multiline:False
BoxLayout:
Custbutton:
text:'Go'
on_press:check.valid(entry_username.text,entry_password.text)
# i want to exectute on_release: app.root.current = "userpage" when its true ?????????????
<UserPage>:
name: "userpage"
Button:
text: "back"
on_release: app.root.current = "Admin"
python kivy kivy-language
What "1" do you mean?
– eyllanesc
Nov 9 at 4:03
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
Hello i have an application in kivy which has username and password
when user enter admin admin it goes to python function and say granted now the problem is
whenever it goes to function and execute the function it would return 1 how do i compare that 1 in kivy file as i am not aware of this and searched a lot no luck
import kivy
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.gridlayout import GridLayout
from kivy.uix.popup import Popup
from kivy.uix.label import Label
from kivy.uix.button import Button
import time
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang.builder import Builder
kivy.require('1.10.1')
class Admin(GridLayout,Screen):
def valid(self,u,p):
if "admin" == "admin" and "admin" == "admin":
print('Access Granted !')
else:
print('Invalid User')
class UserPage(Screen):
pass
class ScreenManagement(ScreenManager):
pass
kv_file = Builder.load_file('Admin.kv')
class AdminApp(App):
def build(self):
return kv_file
r=AdminApp()
r.run()
ScreenManagement:
Admin:
UserPage:
<CustLabel@Label>:
font_size:20
<Custbutton@Button>:
font_size:20
<MyPopup@Popup>:
auto_dismiss: False
Button:
text: 'Close me!'
on_release: root.dismiss()
<Admin>:
name: "Admin"
id:check
d_username:entry_username
d_password:entry_password
rows:5
spacing:10
BoxLayout:
CustLabel:
text:'Enter UserName'
TextInput:
id:entry_username
multiline:False
cursor_color: 1, 0, 0, 1
hint_text: 'Username'
padding_x: [50,50]
BoxLayout:
CustLabel:
text:'Enter Password'
TextInput:
id:entry_password
hint_text: 'Password'
padding_x: [50,50]
password: True
multiline:False
BoxLayout:
Custbutton:
text:'Go'
on_press:check.valid(entry_username.text,entry_password.text)
# i want to exectute on_release: app.root.current = "userpage" when its true ?????????????
<UserPage>:
name: "userpage"
Button:
text: "back"
on_release: app.root.current = "Admin"
python kivy kivy-language
Hello i have an application in kivy which has username and password
when user enter admin admin it goes to python function and say granted now the problem is
whenever it goes to function and execute the function it would return 1 how do i compare that 1 in kivy file as i am not aware of this and searched a lot no luck
import kivy
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.gridlayout import GridLayout
from kivy.uix.popup import Popup
from kivy.uix.label import Label
from kivy.uix.button import Button
import time
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang.builder import Builder
kivy.require('1.10.1')
class Admin(GridLayout,Screen):
def valid(self,u,p):
if "admin" == "admin" and "admin" == "admin":
print('Access Granted !')
else:
print('Invalid User')
class UserPage(Screen):
pass
class ScreenManagement(ScreenManager):
pass
kv_file = Builder.load_file('Admin.kv')
class AdminApp(App):
def build(self):
return kv_file
r=AdminApp()
r.run()
ScreenManagement:
Admin:
UserPage:
<CustLabel@Label>:
font_size:20
<Custbutton@Button>:
font_size:20
<MyPopup@Popup>:
auto_dismiss: False
Button:
text: 'Close me!'
on_release: root.dismiss()
<Admin>:
name: "Admin"
id:check
d_username:entry_username
d_password:entry_password
rows:5
spacing:10
BoxLayout:
CustLabel:
text:'Enter UserName'
TextInput:
id:entry_username
multiline:False
cursor_color: 1, 0, 0, 1
hint_text: 'Username'
padding_x: [50,50]
BoxLayout:
CustLabel:
text:'Enter Password'
TextInput:
id:entry_password
hint_text: 'Password'
padding_x: [50,50]
password: True
multiline:False
BoxLayout:
Custbutton:
text:'Go'
on_press:check.valid(entry_username.text,entry_password.text)
# i want to exectute on_release: app.root.current = "userpage" when its true ?????????????
<UserPage>:
name: "userpage"
Button:
text: "back"
on_release: app.root.current = "Admin"
python kivy kivy-language
python kivy kivy-language
edited Nov 9 at 3:49
eyllanesc
68.5k93052
68.5k93052
asked Nov 9 at 3:45
Soumil Nitin Shah
1
1
What "1" do you mean?
– eyllanesc
Nov 9 at 4:03
add a comment |
What "1" do you mean?
– eyllanesc
Nov 9 at 4:03
What "1" do you mean?
– eyllanesc
Nov 9 at 4:03
What "1" do you mean?
– eyllanesc
Nov 9 at 4:03
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
The callback does not return anything, in general the properties are used to share states, in this case a BooleanProperty must be created that indicates if it is authenticated or not.
*.py
class Admin(GridLayout,Screen):
isAuthenticated =BooleanProperty(False)
def valid(self,u,p):
if "admin" == "admin" and "admin" == "admin":
print('Access Granted !')
self.isAuthenticated = True
else:
print('Invalid User')
*.kv
Custbutton:
text:'Go'
on_press: check.valid(entry_username.text,entry_password.text)
on_release: if root.isAuthenticated: app.root.current = "userpage"
Although it is not advisable to use on_release to make the Screen change because in general the authentication takes some time so it is better to listen to the change of state:
*.kv
<Admin>:
name: "Admin"
id:check
d_username:entry_username
d_password:entry_password
on_isAuthenticated: if root.isAuthenticated: app.root.current = "userpage"
rows:5
spacing:10
BoxLayout:
CustLabel:
text:'Enter UserName'
TextInput:
id:entry_username
multiline:False
cursor_color: 1, 0, 0, 1
hint_text: 'Username'
padding_x: [50,50]
BoxLayout:
CustLabel:
text:'Enter Password'
TextInput:
id:entry_password
hint_text: 'Password'
padding_x: [50,50]
password: True
multiline:False
BoxLayout:
Custbutton:
text:'Go'
on_press: check.valid(entry_username.text,entry_password.text)
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
The callback does not return anything, in general the properties are used to share states, in this case a BooleanProperty must be created that indicates if it is authenticated or not.
*.py
class Admin(GridLayout,Screen):
isAuthenticated =BooleanProperty(False)
def valid(self,u,p):
if "admin" == "admin" and "admin" == "admin":
print('Access Granted !')
self.isAuthenticated = True
else:
print('Invalid User')
*.kv
Custbutton:
text:'Go'
on_press: check.valid(entry_username.text,entry_password.text)
on_release: if root.isAuthenticated: app.root.current = "userpage"
Although it is not advisable to use on_release to make the Screen change because in general the authentication takes some time so it is better to listen to the change of state:
*.kv
<Admin>:
name: "Admin"
id:check
d_username:entry_username
d_password:entry_password
on_isAuthenticated: if root.isAuthenticated: app.root.current = "userpage"
rows:5
spacing:10
BoxLayout:
CustLabel:
text:'Enter UserName'
TextInput:
id:entry_username
multiline:False
cursor_color: 1, 0, 0, 1
hint_text: 'Username'
padding_x: [50,50]
BoxLayout:
CustLabel:
text:'Enter Password'
TextInput:
id:entry_password
hint_text: 'Password'
padding_x: [50,50]
password: True
multiline:False
BoxLayout:
Custbutton:
text:'Go'
on_press: check.valid(entry_username.text,entry_password.text)
add a comment |
up vote
0
down vote
The callback does not return anything, in general the properties are used to share states, in this case a BooleanProperty must be created that indicates if it is authenticated or not.
*.py
class Admin(GridLayout,Screen):
isAuthenticated =BooleanProperty(False)
def valid(self,u,p):
if "admin" == "admin" and "admin" == "admin":
print('Access Granted !')
self.isAuthenticated = True
else:
print('Invalid User')
*.kv
Custbutton:
text:'Go'
on_press: check.valid(entry_username.text,entry_password.text)
on_release: if root.isAuthenticated: app.root.current = "userpage"
Although it is not advisable to use on_release to make the Screen change because in general the authentication takes some time so it is better to listen to the change of state:
*.kv
<Admin>:
name: "Admin"
id:check
d_username:entry_username
d_password:entry_password
on_isAuthenticated: if root.isAuthenticated: app.root.current = "userpage"
rows:5
spacing:10
BoxLayout:
CustLabel:
text:'Enter UserName'
TextInput:
id:entry_username
multiline:False
cursor_color: 1, 0, 0, 1
hint_text: 'Username'
padding_x: [50,50]
BoxLayout:
CustLabel:
text:'Enter Password'
TextInput:
id:entry_password
hint_text: 'Password'
padding_x: [50,50]
password: True
multiline:False
BoxLayout:
Custbutton:
text:'Go'
on_press: check.valid(entry_username.text,entry_password.text)
add a comment |
up vote
0
down vote
up vote
0
down vote
The callback does not return anything, in general the properties are used to share states, in this case a BooleanProperty must be created that indicates if it is authenticated or not.
*.py
class Admin(GridLayout,Screen):
isAuthenticated =BooleanProperty(False)
def valid(self,u,p):
if "admin" == "admin" and "admin" == "admin":
print('Access Granted !')
self.isAuthenticated = True
else:
print('Invalid User')
*.kv
Custbutton:
text:'Go'
on_press: check.valid(entry_username.text,entry_password.text)
on_release: if root.isAuthenticated: app.root.current = "userpage"
Although it is not advisable to use on_release to make the Screen change because in general the authentication takes some time so it is better to listen to the change of state:
*.kv
<Admin>:
name: "Admin"
id:check
d_username:entry_username
d_password:entry_password
on_isAuthenticated: if root.isAuthenticated: app.root.current = "userpage"
rows:5
spacing:10
BoxLayout:
CustLabel:
text:'Enter UserName'
TextInput:
id:entry_username
multiline:False
cursor_color: 1, 0, 0, 1
hint_text: 'Username'
padding_x: [50,50]
BoxLayout:
CustLabel:
text:'Enter Password'
TextInput:
id:entry_password
hint_text: 'Password'
padding_x: [50,50]
password: True
multiline:False
BoxLayout:
Custbutton:
text:'Go'
on_press: check.valid(entry_username.text,entry_password.text)
The callback does not return anything, in general the properties are used to share states, in this case a BooleanProperty must be created that indicates if it is authenticated or not.
*.py
class Admin(GridLayout,Screen):
isAuthenticated =BooleanProperty(False)
def valid(self,u,p):
if "admin" == "admin" and "admin" == "admin":
print('Access Granted !')
self.isAuthenticated = True
else:
print('Invalid User')
*.kv
Custbutton:
text:'Go'
on_press: check.valid(entry_username.text,entry_password.text)
on_release: if root.isAuthenticated: app.root.current = "userpage"
Although it is not advisable to use on_release to make the Screen change because in general the authentication takes some time so it is better to listen to the change of state:
*.kv
<Admin>:
name: "Admin"
id:check
d_username:entry_username
d_password:entry_password
on_isAuthenticated: if root.isAuthenticated: app.root.current = "userpage"
rows:5
spacing:10
BoxLayout:
CustLabel:
text:'Enter UserName'
TextInput:
id:entry_username
multiline:False
cursor_color: 1, 0, 0, 1
hint_text: 'Username'
padding_x: [50,50]
BoxLayout:
CustLabel:
text:'Enter Password'
TextInput:
id:entry_password
hint_text: 'Password'
padding_x: [50,50]
password: True
multiline:False
BoxLayout:
Custbutton:
text:'Go'
on_press: check.valid(entry_username.text,entry_password.text)
answered Nov 9 at 4:13
eyllanesc
68.5k93052
68.5k93052
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53219566%2flogin-ui-in-kivy%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What "1" do you mean?
– eyllanesc
Nov 9 at 4:03