我正在使用Kivy创建注册表单。我希望文本框中的文本在表单加载为不可编辑时出现。从下面可以看出,我可以编辑" Name"领域为" Na"。我希望用户输入名称不能退格并删除" Name"。
这是我的代码:
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.floatlayout import FloatLayout
import xml.etree.cElementTree as ET
import fileinput
import sys
import os
Builder.load_string("""
<Reg>:
# This are attributes of the class Reg now
a: _a
b: _b
c: _c
d: _d
e: _e
f: _f
g: _g
result: _result
AnchorLayout:
anchor_x: 'center'
anchor_y: 'top'
ScreenManager:
size_hint: 1, .9
id: _screen_manager
Screen:
name: 'screen1'
GridLayout:
cols:1
TextInput:
id: _a
text: 'Name: '
TextInput:
id: _b
text: 'Age: '
TextInput:
id: _c
text: 'Phone: '
TextInput:
id: _d
text: 'Email: '
TextInput:
id: _e
text: 'Address: '
TextInput:
id: _f
text: 'Guardian Name: '
TextInput:
id: _g
text: 'Guardian Phone: '
Label:
id: _result
Button:
text: 'Register Me'
# Or you can call a method from the root class (instance of calc)
on_press: root.genxml(*args)
Screen:
name: 'screen2'
Label:
text: 'The second screen'
""")
答案 0 :(得分:3)