When I run the code I get an invalid property name error for the 24th line ("root.manager.transition.direction = 'left'"),
MDScreen:
name:"main"
MDFloatLayout:
md_bg_color: 0.149,0.654,0.352,1
Image:
source: "main_photo_1.png"
pos_hint: {"center_x": .5, "center_y": .65}
size_hint: .5,.5
MDLabel:
text: "'welcome"
font_size: 30
pos_hint: {"center_y": .34}
halign: "center"
color: rgba(34,34,34,255)
Button:
text: ""
size_hint: .66, .065
background_color: 0,0,0,0
Image:
source: "log in.png"
center_x: self.parent.center_x
center_y: self.parent.center_y
on_press:
root.manager.transition.direction = 'left'
root.manager.current = "login"
also, here is the python code:
from kivymd.app import MDApp
from kivy.uix.screenmanager import ScreenManager
from kivy.core.window import Window
from kivy.core.text import LabelBase
from kivy.lang import Builder
Window.size = (310,580)
Builder.load_file("login.kv")
class MyApp(MDApp):
def build(self):
screen_manager = ScreenManager()
screen_manager.add_widget(Builder.load_file('main.kv'))
return screen_manager
MyApp().run()
How should I fix this issue?
I believe the properties/events of a widget in the kv
must appear before its children. Try moving the on_press
to before the Image
:
Button:
text: ""
size_hint: .66, .065
background_color: 0,0,0,0
on_press:
root.manager.transition.direction = 'left'
root.manager.current = "login"
Image:
source: "log in.png"
center_x: self.parent.center_x
center_y: self.parent.center_y