问题
Hi im having issues with using the input_type property of kivy's textinput widget. The thing is i made two custom text input one i called StrText where i set input_type = 'text'. Then a second text input named NumText with input_type = 'number'. I tested this on my phone using kivy launcher, and noticed that once i tap on the NumText input and it brings a number keyboard, if i tap on the StrText, it brings the same number keyboard instead of a normal text keyboard. If you play with it a little you'll notice mostly number key board is returned most of the time. Please is there something wrong with my code, or how can i fix this? You'll find my code below
main.py
from kivy.app import App
from kivy.uix.bubble import Bubble
from kivy.core.window import Window
class BubbleApp(App):
pass
if __name__ == '__main__':
Window.fullscreen = False
BubbleApp().run()
bubble.kv
GridLayout:
cols: 1
StrText:
height: '48dp'
size_hint_y: None
Label:
text: 'Number keyboard below'
height: '48dp'
size_hint_y: None
multiline: False
font_size: self.height * .5
NumText:
height: '48dp'
size_hint_y: None
<StrText@TextInput>:
input_type: 'text'
multiline: False
font_size: self.height * .5
<NumText@TextInput>:
input_type: 'number'
input_filter: 'int'
multiline: False
font_size: self.height *.5
回答1:
Recently I faced similar issue when I built my App using Kivy1.10.0. I used the default keyboard app in android but still it was keep changing from Numeric Keypad to Text Keypad.
This time I tried kivy==1.9.1 with Cython==0.23.1 and buildozer==0.32 to build the .apk and it worked for me.
Note:
I suggest to create a virtualenv to install above specific packages and use it to create the .apk file.
virtualenv build32env
source build32env/bin/activate
pip install buildozer==0.32 Cython==0.23.1
After executing buildozer init
make sure to change buildozer.spec
file:
from
requirements = kivy
to
requirements = kivy==1.9.1
otherwise it will use the latest kivy version to build the .apk file.
More details about buildozer
Hope it helps others!
来源:https://stackoverflow.com/questions/36989388/issue-using-kivy-textinputs-input-type-property