jayyu3333

main program not get insise Keypad

Dec 27th, 2021
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 9.44 KB | None | 0 0
  1.  
  2. from kivy.lang import Builder
  3. from kivymd.app import MDApp
  4.  
  5. from kivymd.uix.screen import MDScreen
  6. from kivy.uix.screenmanager import ScreenManager
  7.  
  8. from kivy.config import Config
  9. Config.set('kivy', 'keyboard_mode', 'dock')
  10.  
  11. from kivymd.app import MDApp
  12. from kivy.lang import Builder
  13. from kivymd.uix.screen import MDScreen
  14. from kivy.uix.screenmanager import ScreenManager
  15. from kivymd.uix.textfield import MDTextFieldRound
  16. from kivy.properties import NumericProperty
  17. from kivy.core.window import Window
  18. from kivy.uix.scrollview import ScrollView
  19. import re
  20.  
  21.  
  22.  
  23. #timeday=ObjectProperty()
  24.  
  25. KV=('''
  26. <LOGIN_Window>:
  27.    name:'login_window1'
  28.    RelativeLayout:
  29.        MDToolbar:
  30.            title: 'Permit Me'
  31.            elevation: 10
  32.            left_action_items: [['menu', lambda x: nav_drawer.set_state('open')]]
  33.            pos_hint: {"left":1, "top":1}
  34.                    
  35.        MDLabel:
  36.            text:'PERMIT ME MOBILE'
  37.            font_size: 50 #cm(10), cm(10)
  38.            pos_hint: {'x':.3, 'y':.3}
  39.            
  40.  
  41.        MDLabel:
  42.            text:'Email-ID'
  43.            #halign:'center'
  44.            pos_hint : {'x':.3, 'y':.2}
  45.                
  46.        MDTextFieldRound:
  47.            id: login
  48.            hint_text: 'For Eg:- [email protected]'
  49.            icon_left: "email"
  50.            halign: 'left'
  51.            valign: 'middle'
  52.            pos_hint : {'x':.3, 'y':.63}
  53.            size_hint : 0.4, .047
  54.            #pos_hint ={'center_x':.7, 'center_y':.5}
  55.                
  56.                
  57.  
  58.                    
  59.        MDLabel:
  60.            text:'Password'
  61.            pos_hint : {'x':.3, 'y':.1}
  62.  
  63.        MDTextFieldRound:
  64.            id: passw
  65.            hint_text: 'Password'
  66.            icon_left: 'key-variant'
  67.            icon_right: 'eye-off'
  68.            pos_hint : {'x':.3, 'y':.53}
  69.            size_hint : 0.4, .047
  70.            
  71.        MDFillRoundFlatButton:
  72.            id: logIn
  73.            text: 'Login'
  74.            pos_hint : {'x':.3, 'y':.4}
  75.            on_release:
  76.                app.change_screen('tolBar_Window1')
  77.                app.add_datatable()
  78.                app.on_start()
  79.                #on_release: app.on_start()
  80.  
  81.        MDFillRoundFlatButton:
  82.            text: 'Register'
  83.            pos_hint : {'x':.6, 'y':.4}
  84.            on_release:root.manager.current = 'regitration_window1'
  85.  
  86.  
  87.        MDLabel:
  88.            text:'Powered By KO-AAHAM Technology'
  89.            pos_hint : {'x':0, 'y':-0.48}
  90.  
  91.  
  92.  
  93.  
  94.    MDNavigationDrawer:
  95.        id:nav_drawer
  96.        
  97.            
  98.        ScrollView:
  99.            MDList:
  100.            #orientation: 'vertical'
  101.                padding: '8dp'
  102.                spacing: '8dp'
  103.        
  104.                    
  105.                MDRoundFlatIconButton:
  106.                    icon: 'account-settings'
  107.                    text: 'Server Setting'
  108.                    on_press: app.change_screen('Server_Setting_window1')
  109.                    
  110.                    
  111.                MDRoundFlatIconButton:
  112.                    text: 'Support'
  113.                    icon: 'face-agent'
  114.                    on_press:app.change_screen('Support_window1')
  115.  
  116.                MDRoundFlatIconButton:
  117.                    icon: 'information-outline'
  118.                    text: 'About'
  119.                    on_press:app.change_screen('About_window1')
  120.        #ContentNavigationDrawer:
  121.  
  122. <REGITRATION_Window>:
  123.    name:'regitration_window1'
  124.    #RelativeLayout:
  125.  
  126.    MDToolbar:
  127.        title: 'Registration'
  128.        elevation: 10
  129.        left_action_items: [['arrow-left', lambda x: app.change_screen('login_window1')]]
  130.        pos_hint: {"left":1, "top":1}
  131.  
  132.    MDLabel:
  133.        text: 'Full Name'
  134.        font_size: 15
  135.        pos_hint : {'x':0.0322, 'y':0.35}
  136.        
  137.    MainKeypad:
  138.        max_characters: 70
  139.        hint_text: 'For Eg:- xxx yyy zzz'
  140.        pos_hint : {'x':0.0322, 'y':0.790}
  141.        size_hint : 0.6, .045
  142.  
  143.  
  144.    MDLabel:
  145.        text: 'Country Code '
  146.        font_size: 15
  147.        pos_hint : {'x':0.0322, 'y':0.272}
  148.        
  149.    NumericInput:
  150.        max_characters: 3
  151.        int_text: 'For Eg:- +91'
  152.        pos_hint : {'x':0.0322, 'y':0.710}
  153.        size_hint : 0.09, .045
  154.  
  155.    MDLabel:
  156.        text: 'Mobile Number'
  157.        font_size: 15
  158.        pos_hint : {'x':0.305, 'y':0.272}
  159.        
  160.    NumericInput:
  161.        max_characters: 10
  162.        hint_text: 'For Eg:- 987654321'
  163.        pos_hint :{'x':0.305, 'y':0.710}
  164.        size_hint : 0.35, .045
  165.                
  166.  
  167.    MDLabel:
  168.        text: 'Location'
  169.        font_size: 15
  170.        pos_hint : {'x':0.0322, 'y':0.190}
  171.        
  172.    MainKeypad:
  173.        max_characters: 70
  174.        hint_text: 'For Eg:- kalyan'
  175.        pos_hint : {'x':0.0322, 'y':0.630}
  176.        size_hint : 0.6, .045
  177.  
  178.    MDLabel:
  179.        text: 'Pin Code'
  180.        font_size: 15
  181.        pos_hint : {'x':0.0322, 'y':0.11}
  182.        
  183.    NumericInput:
  184.        max_characters: 7
  185.        hint_text: 'For Eg:- 400050'
  186.        pos_hint : {'x':0.0322, 'y':0.550}
  187.        size_hint : 0.6, .045
  188.  
  189.    MDLabel:
  190.        text: 'City/Town/Village'
  191.        font_size: 15
  192.        pos_hint : {'x':0.0322, 'y':0.03}
  193.        
  194.    MainKeypad:
  195.        max_characters: 70
  196.        hint_text: 'For Eg:- Mumbai'
  197.        pos_hint : {'x':0.0322, 'y':0.470}
  198.        size_hint : 0.6, .045
  199.  
  200.    MDLabel:
  201.        text: 'District/Taluka'
  202.        font_size: 15
  203.        pos_hint : {'x':0.0322, 'y':-0.05}
  204.        
  205.    MainKeypad:
  206.        max_characters: 70
  207.        hint_text: 'For Eg:- Mumbai'
  208.        pos_hint : {'x':0.0322, 'y':0.390}
  209.        size_hint : 0.6, .045
  210.  
  211.    MDLabel:
  212.        text: 'State'
  213.        font_size: 15
  214.        pos_hint : {'x':0.0322, 'y':-0.13}
  215.        
  216.    MainKeypad:
  217.        max_characters: 70
  218.        hint_text: 'For Eg:- Maharashtra'
  219.        pos_hint : {'x':0.0322, 'y':0.310}
  220.        size_hint : 0.6, .045
  221.  
  222.    MDLabel:
  223.        text: 'Country'
  224.        font_size: 15
  225.        pos_hint : {'x':0.0322, 'y':-0.21}
  226.        
  227.    MainKeypad:
  228.        max_characters: 70
  229.        hint_text: 'For Eg:- India'
  230.        pos_hint : {'x':0.0322, 'y':0.230}
  231.        size_hint : 0.6, .045
  232.  
  233.    MDLabel:
  234.        text: 'Password'
  235.        font_size: 15
  236.        pos_hint : {'x':0.0322, 'y':-0.29}
  237.        
  238.    MainKeypad:
  239.        id: field_password
  240.        max_characters: 70          
  241.        hint_text: 'For Eg:- Chennai@123'
  242.        pos_hint : {'x':0.0322, 'y':0.150}
  243.        size_hint : 0.6, .045
  244.            
  245.    MDLabel:
  246.        text: 'Confirm Password'
  247.        font_size: 15
  248.        pos_hint : {'x':0.0322, 'y':-0.37}
  249.        
  250.    MainKeypad:
  251.        id: field_confirmpassword
  252.        max_characters: 70          
  253.        hint_text: 'For Eg:- Chennai@123'
  254.        password: True
  255.        pos_hint : {'x':0.0322, 'y':0.070}
  256.        size_hint : 0.6, .045
  257.  
  258.    MDLabel:
  259.        id: is_vallid
  260.        #text: 'Vallidation'
  261.        font_size: 45
  262.        pos_hint : {'x':0.67, 'y':0.38}
  263.            
  264.    MDFillRoundFlatButton:
  265.        text:'REGISTER'
  266.        pos_hint: {'x':.1, 'y':.1}
  267.        on_press: app.vall()
  268.  
  269.    MDFillRoundFlatButton:
  270.        text:'Cancel'
  271.        pos_hint: {'x':.3, 'y':.1}
  272.  
  273.  
  274. WindowManager:
  275.    LOGIN_Window:
  276.  
  277.    REGITRATION_Window:
  278.  
  279.    
  280.  
  281.  
  282.        ''')
  283.  
  284.  
  285.  
  286. class LOGIN_Window(MDScreen):
  287.     pass
  288.  
  289.  
  290. class REGITRATION_Window(MDScreen):
  291.     pass
  292.  
  293. class WindowManager(ScreenManager):
  294.     pass
  295.  
  296.  
  297. class NumericInput(MDTextFieldRound):
  298.     max_characters = NumericProperty()
  299.  
  300.     def __init__(self, **kwargs):
  301.         super().__init__(input_filter=self.char_limit, **kwargs)
  302.  
  303.     def on_focus(self, instance_text_field, focus_value: bool):
  304.         if focus_value:
  305.             num_kb = Window.request_keyboard(self.close_key, self)
  306.             if num_kb.widget:
  307.                 num_kb.widget.layout ='numeric.json'
  308.  
  309.     def close_key(self):
  310.         pass
  311.  
  312.     def char_limit(self, substring, from_undo):
  313.         if len(self.text) < self.max_characters:
  314.             return substring
  315.  
  316.  
  317. class MainKeypad(MDTextFieldRound):
  318.     def __init__(self, **kwargs):
  319.         super().__init__(input_filter=self.char_limit, **kwargs)
  320.  
  321.     def on_focus(self, instance_text_field, focus_value: str):
  322.        
  323.         if focus_value:
  324.             kb = Window.request_keyboard(self.close_key, self)
  325.             if kb.widget:
  326.                 kb.widget.layout = 'qwerty'
  327.  
  328.     def close_key(self):
  329.         pass
  330.  
  331.     def char_limit(self, substring, from_undo):
  332.         if len(self.text) < self.max_characters:
  333.             return substring
  334.  
  335.  
  336. class MainApp(MDApp):
  337.     def build(self):
  338.         return Builder.load_string(KV)
  339.  
  340.     def change_screen(self, screen):
  341.         self.root.current = screen
  342.  
  343.     def vall(self):
  344.         self.root.get_screen('regitration_window1').ids.is_vallid.text=""
  345.         main_pswd = self.root.get_screen('regitration_window1').ids.field_password.text
  346.         confirm_pswd=self.root.get_screen('regitration_window1').ids.field_confirmpassword.text
  347.  
  348.         reg = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!#%*?&]{6,16}$"
  349.  
  350.         match_re = re.compile(reg)
  351.  
  352.         main_res = re.search(match_re, main_pswd)
  353.         confirm_res = re.search(match_re, confirm_pswd)
  354.  
  355.         if (main_res==confirm_res):
  356.             self.root.get_screen('regitration_window1').ids.is_vallid.text = "Error"
  357.         else:
  358.             self.change_screen('login_window1')
  359.  
  360. if __name__ == '__main__':  
  361.     MainApp().run()
Advertisement
Add Comment
Please, Sign In to add comment