Multiple Screens But Self.root.ids Retuns An Error
This code actually worked until I added multiple screens. It still works when I remove the multi Screen Manager. I get the attrubite error point to Chapter ids Im trying to add a
Solution 1:
The line:
self.root.ids.Chapter.add_widget(OneLineListItem(text=filename[2:],
on_release=self.play_song,
pos_hint={"center_x": 1, "center_y": 1}, ))
is trying to reference the Chapter
id
as if it were a member of the ScreenManager
(root
) ids
, but it is not. It is a member of the ids
of the BookScreen
. You can fix that error by referencing the BookScreen
instance in the problem line using the get_screen()
method of ScreenManager
:
self.root.get_screen('BooksScreen1').ids.Chapter.add_widget(OneLineListItem(text=filename[2:],
on_release=self.play_song,
pos_hint={"center_x": 1, "center_y": 1}, ))
Post a Comment for "Multiple Screens But Self.root.ids Retuns An Error"