我想在基维启用/禁用Textinput。多个TextInput在那里。 (1)当我点击一个TextInput时,那个特定的TextInput将是可编辑的。 (2)默认情况下,所有内容都将设置为禁用模式。 (3)滚动条应该在那里,假设有数百个输入在那里(我无法提供)。 (4)我面临的另一个问题是:当有数百个输入时,TextInput的文本不能正确显示。那么是否有任何选项可以设置默认大小,以便它不会影响是否只有2-3个输入或100个输入。 (5)TextInput和label处的值应该是动态的,应该存储在全局变量中。 @PalimPalim已经帮助我了解现有的代码。谢谢大家。如何启用/禁用多个TextInput在聚焦在基尼在python
from kivy.app import App
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import StringProperty
from kivy.uix.textinput import TextInput
from kivy.lang import Builder
kivy.uix.scrollview import ScrollView
from kivy.properties import StringProperty
ROWS = ['ac', 'asd', 'kjhgf', 'b' ,'bn', 'sdf', 'ytrwd', 'hfs' ,'erf', ...]
Builder.load_string("""
<Test>:
do_default_tab: False
TabbedPanelItem:
text: 'page1'
scrollView:
size_hint: (None, None)
size: (400, 400)
Table:
padding: 50, 50, 50, 50
orientation: 'vertical'
<Row>:
spacing: 50
size_hint: 1, .9
txt: txtinpt.text
Label:
text: root.txt
TextInput:
id: txtinpt
text: root.txt
Button:
text: 'save'
""")
class Table(BoxLayout):
def __init__(self, **kwargs):
super(Table, self).__init__(**kwargs)
for row in ROWS:
self.add_widget(Row(row))
class Row(BoxLayout):
txt = StringProperty()
def __init__(self, row, **kwargs):
super(Row, self).__init__(**kwargs)
self.txt = row
class ScrollableLabel(ScrollView):
text = StringProperty('')
class Test(TabbedPanel):
pass
class MyApp(App):
def build(self):
test = Test()
return test
if __name__ == '__main__':
MyApp().run()
清晰地解释,谢谢@Tshirtman! – crazyDelight
删除标签的更新很简单,只需删除“text:txtinpt。文本“行规则,它只会在你现在保存该值时更新,对于其他的事情,向你的Row类添加属性,并在字典中使用相同的名称传递它们,它会自动工作。 –
Tshirtman
when我在行规则中添加了更多的TextInput,它显示“声明后无效的数据”,并且在字典中传递属性时,它在枚举过程中显示:“ValueError:需要超过2个值才能解包”。 – crazyDelight