如何使 kivy 中的 treeview 标签可见背景色

how to make the treeview label in kivy visible background color

我正在尝试让我的树视图标签可见,我的意思是当我进行树视图和 运行 并展开树时,我可以看到问题是其他 UI 元素(例如文本输入)是可见的,我不想要那个,如果它在文本输入上方,我无法进行选择

from kivy.uix.treeview import TreeViewLabel,TreeView, TreeViewNode
from kivy.app import App
from kivy.uix.textinput import TextInput
from kivy.uix.boxlayout import BoxLayout
class Accounting(App):
    def build(self):
        tree=TreeView(hide_root=True)
        root=tree.add_node(TreeViewLabel(text='choose'))
        for a in range(100):
            tree.add_node(TreeViewLabel(text=str(a),even_color=(0,0,0,0)),root)
        # if you try here to change the color visibility the numbers will appears but you can't select it
        textinput=TextInput(hint_text='textinput',foreground_color=(1,1,1,1),background_color=(0,0,0,0))
    
        layout=BoxLayout(orientation='vertical')
        layout.add_widget(tree)
        layout.add_widget(textinput)

        return layout

Accounting().run()

尝试这样的事情。没有必要隐藏文本字段,但对我来说看起来更好

from kivy.app import App
from kivy.uix.treeview import TreeViewLabel
from kivy.lang import Builder

KV = """
FloatLayout:
    TextInput:
        id: text_field
        size_hint_y: None
        pos_hint: {'center_y': 0.5}
        height: self.minimum_height
        
    ScrollView:
        TreeView:
            id: tv
            size_hint_y: None
            height: self.minimum_height
            hide_root: True
            on_node_expand: app.hide(True)
            on_node_collapse: app.hide(False)
"""


class Accounting(App):
    def build(self):
        return Builder.load_string(KV)

    def on_start(self):
        root = self.root.ids.tv.add_node(TreeViewLabel(text="Choose"))
        for a in range(100):
            self.root.ids.tv.add_node(TreeViewLabel(text=str(a)), root)

    def hide(self, hide):
        if hide:
            self.root.ids.text_field.foreground_color = (1, 1, 1, 1)
            self.root.ids.text_field.background_color = (0, 0, 0, 0)
        else:
            self.root.ids.text_field.foreground_color = (0, 0, 0, 1)
            self.root.ids.text_field.background_color = (1, 1, 1, 1)


Accounting().run()