使用Kivy TextInput的'input_type'属性时出现问题 [英] Issue using kivy textinput's 'input_type' property

查看:225
本文介绍了使用Kivy TextInput的'input_type'属性时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我在使用kivy的textinput小部件的input_type属性时遇到问题.问题是我做了两个自定义文本输入,一个叫做StrText,在其中我设置了input_type ='text'.然后,第二个文本输入名为NumText,其input_type ='number'. 我使用kivy启动器在手机上对其进行了测试,并注意到,一旦我点击NumText输入并带来了数字键盘,如果我点击了StrText,它将带来相同的数字键盘,而不是普通的文本键盘.如果稍微玩一下,您会发现大多数时候大部分都是数字键盘返回的. 请问我的代码有什么问题,或者我该如何解决? 您将在下面找到我的代码

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

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

推荐答案

最近,当我使用Kivy1.10.0构建应用程序时,遇到了类似的问题.我在android中使用了默认的键盘应用程序,但它仍然从数字键盘更改为文本键盘.

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.

这次,我尝试使用Cython == 0.23.1和buildozer == 0.32来使用kivy == 1.9.1来构建.apk,它对我有用.

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.

注意:

我建议创建一个virtualenv来安装上述特定软件包,并使用它来创建.apk文件.

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

执行buildozer init后,请确保更改buildozer.spec文件:

After executing buildozer init make sure to change buildozer.spec file:

来自

requirements = kivy

requirements = kivy==1.9.1

否则它将使用最新的kivy版本来构建.apk文件.

otherwise it will use the latest kivy version to build the .apk file.

有关buildozer的更多详细信息

希望对其他人有帮助!

这篇关于使用Kivy TextInput的'input_type'属性时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆