小编cra*_*ght的帖子

如何在 python 中使用 kivy 在 TextInput 中启用/禁用编辑

我有一段代码。(1) TextInput 的值应该是显示出来的,但首先它应该是不可编辑的,点击对应的CheckBox后,TextInput是可编辑的。
(2) 使用迭代,Label 和TextInput 应该得到值。Label 和 TextInput 的值不应该被硬编码(尽管它在我的代码中,@FJSevilla 帮助我完成了这个)。
(3) 但是Label和TextInput的值是以json格式存储在一个变量中的。像这样(你可以考虑像映射中的键,值对)[变量 = '{"a" : " Goc" , "b" : "Coc", "c" : "Dow" } '](你可以看到示意图以获取更多间隙)。我很感激你的帮助。

from kivy.app import App
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.lang import Builder

Builder.load_string("""

<Test>:
    do_default_tab: False

    TabbedPanelItem:
        text: 'page1'

        BoxLayout:
            padding: 50, 50, 50, 50
            orientation: 'horizontal'

            BoxLayout:
                spacing: 50
                orientation: 'vertical'
                size_hint_x: 1
                Label:
                    text: 'a'
                Label:
                    text: 'b'
                Label:
                    text: 'c'

            BoxLayout:
                spacing: 50
                orientation: 'vertical'
                TextInput:
                    text: 'Goc'
                TextInput:
                    text: …
Run Code Online (Sandbox Code Playgroud)

python user-interface edit textinput kivy

5
推荐指数
1
解决办法
4723
查看次数

标签 统计

edit ×1

kivy ×1

python ×1

textinput ×1

user-interface ×1