Python 如何根据显示的MDBottomNavigationItem更改MDToolbar的标题
我正在使用KivyMD开发一个应用程序(至少在尝试)。要导航,我想使用MDBottomNavigation。我的问题是,我还想用MDToolbar显示标题,“链接”到显示的内容。我的.kv文件如下所示:Python 如何根据显示的MDBottomNavigationItem更改MDToolbar的标题,python,kivy,kivy-language,Python,Kivy,Kivy Language,我正在使用KivyMD开发一个应用程序(至少在尝试)。要导航,我想使用MDBottomNavigation。我的问题是,我还想用MDToolbar显示标题,“链接”到显示的内容。我的.kv文件如下所示: BoxLayout: orientation: 'vertical' id: blayout MDToolbar: title: "1" if... else "2" MDBottomNavigation: id: naviga
BoxLayout:
orientation: 'vertical'
id: blayout
MDToolbar:
title: "1" if... else "2"
MDBottomNavigation:
id: navigation
MDBottomNavigationItem:
text: "xxx"
MDBottomNavigationItem:
text: "yyy"
我只是不知道该在if和else之间设置什么,我想我必须检查显示的是哪个选项卡(使用ID?),但我不知道如何执行此操作,而且我没有发现任何线索。这就是方法:
BoxLayout:
orientation: 'vertical'
id: blayout
MDToolbar:
id: toolbar
title: "1"
MDBottomNavigation:
id: navigation
MDBottomNavigationItem:
text: "xxx"
on_tab_release: toolbar.title = "1"
MDBottomNavigationItem:
text: "yyy"
on_tab_release: toolbar.title = "2"