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"









share|improve this question
























  • What "1" do you mean?
    – eyllanesc
    Nov 9 at 4:03















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"









share|improve this question
























  • What "1" do you mean?
    – eyllanesc
    Nov 9 at 4:03













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"









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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












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)





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    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

























    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)





    share|improve this answer

























      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)





      share|improve this answer























        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)





        share|improve this answer












        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)






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 9 at 4:13









        eyllanesc

        68.5k93052




        68.5k93052






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            how to define a CAPL function taking a sysvar argument

            How do I alter this code to allow abstract classes or interfaces to work over identical auto generated...

            Krisenintervention