I am in a screen called Riddles in a boxlayout named Riddlepage. Now I try to create an on_press action and associate to all buttons in the layout. This action is supposed to take me to a new screen called 'page2'. I get the following error: AttributeError: 'kivy.properties.ObjectProperty' object has no attribute 'current'
What I have tried:
I used this in the on_press function
def picture(self,a):
img=Image (source=a+'.jpg')
page2.manager.current="page2"
Here is more part of th code
class Riddles(Screen):
pass
class Riddlepage(BoxLayout):
def __init__(self, **kwargs):
self.pp = open("riddle.txt", "r")
super().__init__(**kwargs)
self.orientation = "vertical"
self.spacing = dp(5)
self.pos_hint = {"top": 1}
for line in self.pp.readlines():
b = Button(text=line, size_hint=(.8, None), pos_hint={"x": .1}, height=(dp(40)),background_color=(0,0,1),border=(30,30,30,30))
b.bind(on_press=lambda x:self.picture(line))
self.add_widget(b)
self.pp.close()
def picture(self,a):
img=Image(source=a+".jpg")
Page2.manager.current="Page2"
class MainApp(App):
with open("profile.txt", "r", encoding="utf-8") as file:
info = file.readlines()
def build(self):
sm=ScreenManager()
sm.add_widget(Page1(name="Page1"))
sm.add_widget(Riddles(name="Riddles"))
sm.add_widget(Coursewindow(name="Coursewindow"))
sm.add_widget(Ancienwindow(name="Ancienwindow"))
sm.add_widget(Level(name="Level"))
sm.add_widget(Levels(name="Levels"))
sm.add_widget(Corrections(name="Corrections"))
sm.add_widget(Past_papers(name="Past_papers"))
sm.add_widget(Page2(name="Page2"))
sm.add_widget(Page3(name="3"))
sm.add_widget(Profile(name="Profile"))
return sm
MainApp().run()
kv=
<riddles>:
ScrollView:
Riddlepage:
size_hint:1,None
height:self.minimum_height