'KIVY: Numeric Keyboard ON Text of the Text Field
I am trying to add Numeric Keyboard in UI
Which will be display as clicked on the text on filed
But some how Numeric keyboard not show in the UI
I use numeric.json file to open the numeric keyboard as per the kivy Documentation json file and link is [https://github.com/kivy/kivy/blob/master/examples/keyboard/numeric.json]
here is my code below
enter code here
from kivy.lang import Builder
from kivymd.app import MDApp
from kivymd.uix.screen import MDScreen
from kivy.uix.relativelayout import RelativeLayout
from kivy.uix.screenmanager import ScreenManager
from kivy.core.window import Window
KV= '''
<REGITRATION_Window>:
name:'regitration_window1'
RelativeLayout:
MDToolbar:
title: 'Registraion'
elevation: 10
left_action_items: [['arrow-left']]
pos_hint: {"left":1, "top":1}
MDLabel:
text: 'Country Code '
font_size: 15
pos_hint : {'x':0.0322, 'y':0.272}
MDTextFieldRound:
int_text: 'For Eg:- +91'
pos_hint : {'x':0.0322, 'y':0.710}
size_hint : 0.08, .045
on_text: app.setup_key()
MDLabel:
text: 'Mobile Number'
font_size: 15
pos_hint : {'x':0.305, 'y':0.272}
MDTextFieldRound:
hint_text: 'For Eg:- 987654321'
pos_hint :{'x':0.305, 'y':0.710}
size_hint : 0.35, .045
MDFillRoundFlatButton:
text:'REGISTER'
pos_hint: {'x':.1, 'y':.1}
MDFillRoundFlatButton:
text:'Cancel'
pos_hint: {'x':.3, 'y':.1}
RelativeLayout:
id: data_layout
WindowManager:
REGITRATION_Window:
id: key_num
'''
class REGITRATION_Window(MDScreen):
pass
class WindowManager(ScreenManager):
pass
class MainApp(MDApp):
def build(self):
return Builder.load_string(KV)
def close_key(self):
pass
def setup_key(self):
NumKB = Window.request_keyboard(self.close_key, self)
if NumKB.widget:
NumKB.widget.layout = 'numeric.json'
self.root.ids.key_num.ids.data_layout.add_widget(self.NumKB)
if __name__ == '__main__':
MainApp().run()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
