Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from kivymd.app import MDApp
- from kivy.lang import Builder
- from kivymd.uix.screen import MDScreen
- from kivy.uix.screenmanager import ScreenManager
- from kivy.lang import Builder
- import re
- KV=('''
- <LOGIN_Window>:
- name:'login_window1'
- FloatLayout:
- MDBoxLayout:
- orientation :'vertical'
- MDToolbar:
- title: 'Login Screen'
- elevation: 10
- left_action_items: [['menu', lambda x: nav_drawer.set_state('open')]]
- md_bg_color: 225/255,96/255,1/255,1
- MDLabel:
- MDLabel:
- MDLabel:
- MDBoxLayout:
- orientation :'vertical'
- pos_hint: {'center_x':.5}
- # size_hint:None, None
- size_hint: 0.8, 0.8
- size_hint_y:None
- spacing:'10dp'
- MDLabel:
- text:'Email-ID'
- font_size: '15sp'
- size_hint_y: None
- height: self.texture_size[1] + dp(10)
- color:0,0,0,1
- MDTextFieldRound:
- id:login_emaiid
- hint_text: 'For Eg:- [email protected]'
- icon_left: "email"
- input_type:'text'
- icon_left_color:[0,0,0,1]
- hint_text_color:0,0,0,1
- icon_right_color:[0,0,0,1]
- foreground_color:0,0,0,1
- line_color_focus: 255/255,96/255,1/255,1
- normal_color: [255/255,96/255,1/255,1]
- color_active: [255/255,96/255,1/255,1]
- cursor_color: 0,0,0,1
- #required: True
- on_text_validate: login_passw.focus=True
- on_text:app.logIn_Email_pass_validate()
- multiline: False
- MDLabel:
- text:'Password'
- font_size: '15sp'
- size_hint_y: None
- height: self.texture_size[1] + dp(10)
- color:0,0,0,1
- MDTextFieldRound:
- id:login_passw
- multiline: False
- hint_text: 'Password'
- icon_left: 'key-variant'
- #password: True
- #icon_right:'eye-off'
- input_type:'text'
- icon_left_color:0,0,0,1
- hint_text_color:0,0,0,1
- icon_right_color:0,0,0,1
- foreground_color:0,0,0,1
- line_color_focus: 255/255,96/255,1/255,1
- normal_color: 255/255,96/255,1/255,1
- color_active: 255/255,96/255,1/255,1
- cursor_color: 0,0,0,1
- on_text_validate: login_emaiid.focus=True
- on_text:app.logIn_Email_pass_validate()
- multiline: False
- MDLabel:
- MDFillRoundFlatButton:
- id: logIn
- text: 'Go to Register'
- md_bg_color_disabled: 255/255,96/255,1/255,1
- md_bg_color: 255/255,96/255,1/255,1
- on_release:
- root.manager.current = 'regitration_window1'
- app.Clear_Login()
- MDLabel:
- MDLabel:
- MDLabel:
- <REGITRATION_Window>:
- name:'regitration_window1'
- FloatLayout:
- BoxLayout:
- orientation: 'vertical'
- MDToolbar:
- title: 'Registration Screen'
- elevation: 10
- left_action_items: [['arrow-left', lambda x: app.change_screen('login_window1')]]
- size_hint_y:None
- md_bg_color: 225/255,96/255,1/255,1
- MDLabel:
- MDLabel:
- MDLabel:
- MDBoxLayout:
- orientation :'vertical'
- pos_hint: {'center_x':.5}
- # size_hint:None, None
- size_hint: 0.8, 0.8
- size_hint_y:None
- spacing:'10dp'
- MDLabel:
- text: 'Full Name'
- font_size: '15sp'
- height: self.texture_size[1] + dp(10)
- color:0,0,0,1
- MDTextFieldRound:
- id:field_Name
- hint_text: 'xxx yyy zzz'
- input_type:'text'
- icon_left_color:0,0,0,1
- hint_text_color:0,0,0,1
- icon_right_color:0,0,0,1
- foreground_color:0,0,0,1
- line_color_focus: 255/255,96/255,1/255,1
- normal_color: 255/255,96/255,1/255,1
- color_active: 255/255,96/255,1/255,1
- cursor_color: 0,0,0,1
- helper_text: "or click on forgot username"
- helper_text_mode: "on_focus"
- on_text_validate: field_EmailID.focus=True
- on_text:app.logIn_Email_pass_validate()
- multiline: False
- MDLabel:
- text:'Email-ID'
- font_size: '15sp'
- height: self.texture_size[1] + dp(10)
- color:0,0,0,1
- MDTextFieldRound:
- id:field_EmailID
- hint_text: '[email protected]'
- input_type:'text'
- color:0,0,0,1
- icon_left_color:0,0,0,1
- hint_text_color:0,0,0,1
- icon_right_color:0,0,0,1
- foreground_color:0,0,0,1
- line_color_focus: 255/255,96/255,1/255,1
- normal_color: 255/255,96/255,1/255,1
- color_active: 255/255,96/255,1/255,1
- on_text_validate: field_Contrycode.focus=True
- on_text:app.logIn_Email_pass_validate()
- multiline: False
- MDLabel:
- text: 'Country Code '
- font_size: '15sp'
- height: self.texture_size[1] + dp(10)
- color:0,0,0,1
- MDTextFieldRound:
- id: field_Contrycode
- hint_text: '+91'
- input_type:'number'
- icon_left_color:0,0,0,1
- hint_text_color:0,0,0,1
- icon_right_color:0,0,0,1
- foreground_color:0,0,0,1
- line_color_focus: 255/255,96/255,1/255,1
- normal_color: 255/255,96/255,1/255,1
- color_active: 255/255,96/255,1/255,1
- cursor_color: 0,0,0,1
- on_text_validate: field_MobileNumber.focus=True
- on_text:app.logIn_Email_pass_validate()
- multiline: False
- MDLabel:
- text: 'Mobile Number'
- font_size: '15sp'
- height: self.texture_size[1] + dp(10)
- color:0,0,0,1
- MDTextFieldRound:
- id: field_MobileNumber
- hint_text: '987654321'
- input_type:'number'
- icon_left_color:0,0,0,1
- hint_text_color:0,0,0,1
- icon_right_color:0,0,0,1
- foreground_color:0,0,0,1
- line_color_focus: 255/255,96/255,1/255,1
- normal_color: 255/255,96/255,1/255,1
- color_active: 255/255,96/255,1/255,1
- cursor_color: 0,0,0,1
- input_filter: 'int'
- on_text_validate: field_Location.focus=True
- on_text:app.logIn_Email_pass_validate()
- MDLabel:
- text: 'Password'
- font_size: '15sp'
- height: self.texture_size[1] + dp(10)
- color:0,0,0,1
- MDTextFieldRound:
- id: field_password
- max_characters: 70
- hint_text: 'Chennai@123'
- icon_left_color:0,0,0,1
- hint_text_color:0,0,0,1
- icon_right_color:0,0,0,1
- foreground_color:0,0,0,1
- line_color_focus: 255/255,96/255,1/255,1
- normal_color: 255/255,96/255,1/255,1
- color_active: 255/255,96/255,1/255,1
- cursor_color: 0,0,0,1
- on_text_validate: field_confirmpassword.focus=True
- on_text:app.logIn_Email_pass_validate()
- multiline: False
- MDFillRoundFlatButton:
- text:'Go to Login'
- on_release:
- root.manager.current = 'login_window1'
- app.Clear_Register()
- md_bg_color: 255/255,96/255,1/255,1
- MDLabel:
- MDLabel:
- MDLabel:
- WindowManager:
- LOGIN_Window:
- REGITRATION_Window:
- ''')
- class LOGIN_Window(MDScreen):
- pass
- class REGITRATION_Window(MDScreen):
- pass
- class WindowManager(ScreenManager):
- pass
- class MainApp(MDApp):
- def build(self):
- self.theme_cls.primary_palette = "Orange"
- self.theme_cls.primary_hue = "A700"
- return Builder.load_string(KV)
- regEmailID='^[a-zA-Z0-9]+[\._-]?[a-zA-Z0-9]+[@]\w+[.]\w{2,3}$'
- match_re_EmailID= re.compile(regEmailID)
- regpassword = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*#?&+-/=)(^~`,.<>;:"'"'"'|}{\[\]\s\\\\_])[A-Za-z\d@$!#%*?&+-/=)(^~`,.<>;:"'"'"'|}{\[\]\s\\\\_]{4,18}$"
- match_re_pasword = re.compile(regpassword)
- regName='^([a-zA-Z]+)\s([a-zA-Z]+)*\s([a-z]+)*$'
- match_re_Name = re.compile(regName)
- regContryCode='^\+(\d{1}\-)?(\d{1,3})$'
- match_re_CountryCode = re.compile(regContryCode)
- regMobileNumber='^[1-9]{2}[0-9]{8}$'
- match_re_Mobile = re.compile(regMobileNumber)
- regOnlyALPHA='(^\w+)\s?'
- match_re_OnlyAlpha= re.compile(regOnlyALPHA)
- regPincode= '^[1-9]{1}[0-9]{2}[0-9]{2,6}$'
- match_re_Pincode= re.compile(regPincode)
- def logIn_Email_pass_validate(self):
- if MDApp.get_running_app().root.current== 'login_window1':
- if MDApp.get_running_app().root.get_screen('login_window1').ids.login_emaiid.focus==True:
- if not re.search(self.match_re_EmailID, MDApp.get_running_app().root.get_screen('login_window1').ids.login_emaiid.text):
- MDApp.get_running_app().root.get_screen('login_window1').ids.login_passw.disabled= True
- MDApp.get_running_app().root.get_screen('login_window1').ids.login_emaiid.focus=True
- MDApp.get_running_app().root.get_screen('login_window1').ids.login_emaiid.disabled=False
- MDApp.get_running_app().root.get_screen('login_window1').ids.logIn.disabled=True
- MDApp.get_running_app().root.get_screen('login_window1').ids.login_emaiid.icon_right="text-box-remove"
- elif re.search(self.match_re_EmailID,MDApp.get_running_app().root.get_screen('login_window1').ids.login_emaiid.text):
- MDApp.get_running_app().root.get_screen('login_window1').ids.login_passw.disabled= False
- MDApp.get_running_app().root.get_screen('login_window1').ids.logIn.disabled=False
- MDApp.get_running_app().root.get_screen('login_window1').ids.login_emaiid.icon_right="text-box-check-outline"
- elif MDApp.get_running_app().root.get_screen('login_window1').ids.login_passw.focus==True:
- if not re.search(self.match_re_pasword, MDApp.get_running_app().root.get_screen('login_window1').ids.login_passw.text):
- MDApp.get_running_app().root.get_screen('login_window1').ids.login_emaiid.disabled= True
- MDApp.get_running_app().root.get_screen('login_window1').ids.login_passw.focus=True
- MDApp.get_running_app().root.get_screen('login_window1').ids.login_passw.disabled=False
- MDApp.get_running_app().root.get_screen('login_window1').ids.logIn.disabled=True
- MDApp.get_running_app().root.get_screen('login_window1').ids.login_passw.icon_right="text-box-remove"
- elif re.search(self.match_re_pasword, MDApp.get_running_app().root.get_screen('login_window1').ids.login_passw.text):
- MDApp.get_running_app().root.get_screen('login_window1').ids.login_emaiid.disabled= False
- MDApp.get_running_app().root.get_screen('login_window1').ids.logIn.disabled=False
- MDApp.get_running_app().root.get_screen('login_window1').ids.login_passw.icon_right="text-box-check-outline"
- elif self.root.current == 'regitration_window1':
- if MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_Name.focus==True:
- if not re.search(self.match_re_Name, self.root.get_screen('regitration_window1').ids.field_Name.text):
- self.root.get_screen('regitration_window1').ids.field_EmailID.disabled= True
- self.root.get_screen('regitration_window1').ids.field_Contrycode.disabled= True
- self.root.get_screen('regitration_window1').ids.field_MobileNumber.disabled= True
- self.root.get_screen('regitration_window1').ids.field_password.disabled= True
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_Name.focus=True
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_Name.disabled=False
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_Name.icon_right="text-box-remove"
- elif re.search(self.match_re_Name, self.root.get_screen('regitration_window1').ids.field_Name.text):
- self.root.get_screen('regitration_window1').ids.field_EmailID.disabled= False
- self.root.get_screen('regitration_window1').ids.field_Contrycode.disabled= False
- self.root.get_screen('regitration_window1').ids.field_MobileNumber.disabled= False
- self.root.get_screen('regitration_window1').ids.field_password.disabled= False
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_Name.icon_right="text-box-check-outline"
- elif MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_EmailID.focus==True:
- if not re.search(self.match_re_EmailID, self.root.get_screen('regitration_window1').ids.field_EmailID.text):
- self.root.get_screen('regitration_window1').ids.field_Name.disabled= True
- self.root.get_screen('regitration_window1').ids.field_Contrycode.disabled= True
- self.root.get_screen('regitration_window1').ids.field_MobileNumber.disabled= True
- self.root.get_screen('regitration_window1').ids.field_password.disabled= True
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_EmailID.focus=True
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_EmailID.disabled=False
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_EmailID.icon_right="text-box-remove"
- elif re.search(self.match_re_EmailID, self.root.get_screen('regitration_window1').ids.field_EmailID.text):
- self.root.get_screen('regitration_window1').ids.field_Name.disabled= False
- self.root.get_screen('regitration_window1').ids.field_Contrycode.disabled= False
- self.root.get_screen('regitration_window1').ids.field_MobileNumber.disabled= False
- self.root.get_screen('regitration_window1').ids.field_password.disabled= False
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_EmailID.icon_right="text-box-check-outline"
- elif MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_Contrycode.focus==True:
- if not re.search(self.match_re_CountryCode, self.root.get_screen('regitration_window1').ids.field_Contrycode.text):
- self.root.get_screen('regitration_window1').ids.field_Name.disabled= True
- self.root.get_screen('regitration_window1').ids.field_EmailID.disabled= True
- self.root.get_screen('regitration_window1').ids.field_MobileNumber.disabled= True
- self.root.get_screen('regitration_window1').ids.field_password.disabled= True
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_Contrycode.focus=True
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_Contrycode.disabled=False
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_Contrycode.icon_right="text-box-remove"
- elif re.search(self.match_re_CountryCode, self.root.get_screen('regitration_window1').ids.field_Contrycode.text):
- self.root.get_screen('regitration_window1').ids.field_Name.disabled= False
- self.root.get_screen('regitration_window1').ids.field_EmailID.disabled= False
- self.root.get_screen('regitration_window1').ids.field_MobileNumber.disabled= False
- self.root.get_screen('regitration_window1').ids.field_password.disabled= False
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_Contrycode.icon_right="text-box-check-outline"
- elif MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_MobileNumber.focus==True:
- if not re.search(self.match_re_Mobile, self.root.get_screen('regitration_window1').ids.field_MobileNumber.text):
- self.root.get_screen('regitration_window1').ids.field_Name.disabled= True
- self.root.get_screen('regitration_window1').ids.field_EmailID.disabled= True
- self.root.get_screen('regitration_window1').ids.field_Contrycode.disabled= True
- self.root.get_screen('regitration_window1').ids.field_password.disabled= True
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_MobileNumber.focus=True
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_MobileNumber.disabled=False
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_MobileNumber.icon_right="text-box-remove"
- elif re.search(self.match_re_Mobile, self.root.get_screen('regitration_window1').ids.field_MobileNumber.text):
- self.root.get_screen('regitration_window1').ids.field_Name.disabled= False
- self.root.get_screen('regitration_window1').ids.field_EmailID.disabled= False
- self.root.get_screen('regitration_window1').ids.field_Contrycode.disabled= False
- self.root.get_screen('regitration_window1').ids.field_password.disabled= False
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_MobileNumber.icon_right="text-box-check-outline"
- elif MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_password.focus==True:
- if not re.search(self.match_re_pasword, self.root.get_screen('regitration_window1').ids.field_password.text):
- self.root.get_screen('regitration_window1').ids.field_Name.disabled= True
- self.root.get_screen('regitration_window1').ids.field_EmailID.disabled= True
- self.root.get_screen('regitration_window1').ids.field_Contrycode.disabled= True
- self.root.get_screen('regitration_window1').ids.field_MobileNumber.disabled= True
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_password.focus=True
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_password.disabled=False
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_password.icon_right="text-box-remove"
- elif re.search(self.match_re_pasword, self.root.get_screen('regitration_window1').ids.field_password.text):
- self.root.get_screen('regitration_window1').ids.field_Name.disabled= False
- self.root.get_screen('regitration_window1').ids.field_EmailID.disabled= False
- self.root.get_screen('regitration_window1').ids.field_Contrycode.disabled= False
- self.root.get_screen('regitration_window1').ids.field_MobileNumber.disabled= False
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_password.icon_right="text-box-check-outline"
- def Clear_Register(self):
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_Name.text=""
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_Name.icon_right=""
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_EmailID.text=""
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_EmailID.icon_right=""
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_Contrycode.text=""
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_Contrycode.icon_right=""
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_MobileNumber.text=""
- MDApp.get_running_app().root.get_screen('regitration_window1').ids.field_MobileNumber.icon_right=""
- def Clear_Login(self):
- MDApp.get_running_app().root.get_screen('login_window1').ids.login_emaiid.text=""
- MDApp.get_running_app().root.get_screen('login_window1').ids.login_emaiid.focus=""
- MDApp.get_running_app().root.get_screen('login_window1').ids.login_passw.text=""
- MDApp.get_running_app().root.get_screen('login_window1').ids.login_passw.focus=""
- def change_screen(self, screen):
- MDApp.get_running_app().root.current = screen
- self.Clear_Register()
- self.logIn_Email_pass_validate()
- ()
- if __name__ == '__main__':
- MainApp().run()
Advertisement
Add Comment
Please, Sign In to add comment