Kivy:如何制作一个不可编辑的文本输入框?

9
如何使文本输入框对用户不可编辑?
TextInput:
    id:out
    background_color: (0, 0, 0, 1)
    foreground_color: (0, 1, 0, 1)
    multiline: True
    text:""

2
readonly 属性设置为 True - Simon Mengong
2个回答

12

readonly 属性是你的朋友

TextInput:
    id:out
    background_color: (0, 0, 0, 1)
    foreground_color: (0, 1, 0, 1)
    multiline: True
    text:""
    readonly: True 

做那样甚至不允许我使用箭头键。如何允许至少进行导航? - Vishesh Mangla
@VisheshMangla - 你可以创建一个回调函数,使得每次文本发生更改时,文本都会返回到你所期望的值。 - Yoav Glazner

0

您还可以将TextInput字段设置为禁用状态。

TextInput:
    id:out
    background_color: (0, 0, 0, 1)
    foreground_color: (0, 1, 0, 1)
    multiline: True
    text:""
    disabled: True 

请查看以下答案获取更多信息: https://dev59.com/BaPia4cB1Zd3GeqP1qQ3#45238685


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接