введите изображение описание здесь
Например, на изображении видно, что выбран «Вторичный лист», но на самом деле я нахожусь на «главной странице», только он остается выбранным, хотя окна измененный. Это мой файл kv:
Код: Выделить всё
:
MDScreen:
MDNavigationLayout:
MDScreenManager:
MDScreen:
name: "main_screen"
# Barra superior en la parte superior
MDTopAppBar:
id: top_app_bar
type: "small"
pos_hint: {"top": 1}
MDTopAppBarLeadingButtonContainer:
MDActionTopAppBarButton:
icon: "menu"
on_release: nav_drawer.set_state("toggle")
MDTopAppBarTitle:
text: "Página Principal"
MDNavigationDrawer:
id: nav_drawer
drawer_type: "modal"
MDNavigationDrawerMenu:
MDNavigationDrawerHeader:
orientation: "vertical"
MDLabel:
text: "Menu"
font_style: "Title"
role: "medium"
adaptive_height: True
MDNavigationDrawerDivider:
MDNavigationDrawerItem:
on_release: app.root.current = 'hoja1'
MDNavigationDrawerItemLeadingIcon:
icon: "home"
MDNavigationDrawerItemText:
text: "Página principal"
MDNavigationDrawerItem:
on_release: app.root.current = 'hoja2'
MDNavigationDrawerItemText:
text: "Hoja secundaria"
MDNavigationDrawerItem:
on_release: app.root.current = 'hoja3'
MDNavigationDrawerItemText:
text: "Hoja secundaria 2"
Код: Выделить всё
from kivy.core.window import Window
from kivy.lang import Builder
from kivymd.app import MDApp
from kivymd.uix.screen import MDScreen
from kivymd.uix.screenmanager import MDScreenManager
from kivymd.uix.navigationdrawer import MDNavigationDrawer,MDNavigationLayout, MDNavigationDrawerItem, MDNavigationDrawerItemTrailingText
from kivymd.uix.appbar import MDActionTopAppBarButton, MDFabBottomAppBarButton, MDTopAppBar
Window.size =(400,700)
Builder.load_file('kvs/hoja1.kv')
Builder.load_file('kvs/hoja2.kv')
Builder.load_file('kvs/hoja3.kv')
class WindowManager(MDScreenManager):
pass
class MainScreen(MDScreen):
pass
class SecondaryScreen(MDScreen):
pass
class MainApp(MDApp):
def __init__(self, **kwargs) :
super().__init__(**kwargs)
def build(self):
self.wm = WindowManager()
screens = [
MainScreen(name = 'hoja1'),
SecondaryScreen(name = 'hoja2'),
SecondaryScreen2(name = 'hoja3'),
]
for screen in screens:
self.wm.add_widget(screen)
return self.wm
if __name__== "__main__":
MainApp().run()
Надеюсь, кто-нибудь сможет мне помочь чтобы он не оставался выбранным, когда я меняю страницы и возвращаюсь со страниц.
Спасибо.
Подробнее здесь: https://stackoverflow.com/questions/793 ... tiondrawer
Мобильная версия