Kivy嵌套TabbedPanels无法单击垂直选项卡

时间:2018-03-21 19:08:29

标签: python kivy kivy-language

我正在尝试创建一个嵌套的TabbedPanel布局(实质上,你可以把它想象成战舰网格,如果这简化了事情)。我已经完成了获取我想要的可视化表示,但是无法单击嵌套的TabbedPanel小部件的垂直选项卡。这可能是因为它驻留在父TabbedPanel小部件中,这可能会干扰触发选项卡本身的on_click(或类似)属性的能力。我在下面提供了一个简单的例子。

我还应该澄清,垂直标签中包含的内容会根据不同水平标签的选择(沿着顶部)动态变化。

非常感谢任何见解,提前谢谢!

的Python:

import kivy
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.gridlayout import GridLayout
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.uix.button import Button
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition

#Load kv file
Builder.load_file('test.kv')

class Main_Panel(Screen):

    pass

class Nested_Panel(TabbedPanel):

    pass

class MyScreenManager(ScreenManager):

    pass

class TestingApp(App):

    def build(self):
        self.sm = MyScreenManager()
        return self.sm

if __name__ == '__main__':
    TestingApp().run()

KV:

<MyScreenManager>:

    Main_Panel:
        name: 'main'

<Main_Panel>:

    BoxLayout:

        orientation: 'vertical'
        padding: 20
        spacing: 20

        TabbedPanel:

            do_default_tab: False

            TabbedPanelItem:
                text: 'A'
                Nested_Panel:

            TabbedPanelItem:
                text: 'B'
                Nested_Panel:

            TabbedPanelItem:
                text: 'C'
                Nested_Panel:

        GridLayout:

            cols: 1
            size_hint: 1, .1

            Button:
                text: 'Quit App'
                on_release: app.stop()

<Nested_Panel>:

    do_default_tab: False
    tab_pos: 'left_top'

    TabbedPanelItem:
        text: '1'

    TabbedPanelItem:
        text: '2'

    TabbedPanelItem:
        text: '3'

    TabbedPanelItem:
        text: '4'

    TabbedPanelItem:
        text: '5'

    TabbedPanelItem:
        text: '6'

0 个答案:

没有答案