As commented by Anderson python is case-sensitive (case-sensitive), and according to the kivy documentation the build()
method is in the lowercase (lower case). To correct it, you only have to replace Build()
with build()
Rather wrong:
def Build(self):
self.img1 = Image(source= "images/Logo.jpg",size_hint= (.5, .3),pos_hint={"center_x":.5, "center_y":.9}),
self.img2 = Image(source= "images/super.png",size_hint= (.99, .3), pos_hint={"center_x":.5, "center_y":.65}),
lb1 = Label(text="Usuário: ",font_size= '15sp',size_hint= (None,None),pos_hint= {"center_x":.40, "center_y":.43},bold= True),
lb2 = Label(text="Senha: ",size_hint= (None,None),font_size= "15sp",pos_hint={"center_x":.40, "center_y":.36},bold= True),
lb3 = Label(text="Cadatre-se!",size_hint= (None, None),font_size= "8sp",pos_hint= {"center_x":.5, "center_y":.3},bold= True),
lb4 = Label(text="Esqueceu sua senha?",size_hint= (None, None),font_size= "8sp",pos_hint= {"center_x":.5, "center_y":.32},bold= True)
layoutVideo = FloatLayout()
layoutVideo.add_widget(self.img1)
layoutVideo.add_widget(self.img2)
layoutVideo.add_widget(lb1)
layoutVideo.add_widget(lb2)
layoutVideo.add_widget(lb3)
layoutVideo.add_widget(lb4)
return layoutVideo
Correct, changing Build()
by build()
:
def build(self):
self.img1 = Image(source= "images/Logo.jpg",size_hint= (.5, .3),pos_hint={"center_x":.5, "center_y":.9}),
self.img2 = Image(source= "images/super.png",size_hint= (.99, .3), pos_hint={"center_x":.5, "center_y":.65}),
lb1 = Label(text="Usuário: ",font_size= '15sp',size_hint= (None,None),pos_hint= {"center_x":.40, "center_y":.43},bold= True),
lb2 = Label(text="Senha: ",size_hint= (None,None),font_size= "15sp",pos_hint={"center_x":.40, "center_y":.36},bold= True),
lb3 = Label(text="Cadatre-se!",size_hint= (None, None),font_size= "8sp",pos_hint= {"center_x":.5, "center_y":.3},bold= True),
lb4 = Label(text="Esqueceu sua senha?",size_hint= (None, None),font_size= "8sp",pos_hint= {"center_x":.5, "center_y":.32},bold= True)
layoutVideo = FloatLayout()
layoutVideo.add_widget(self.img1)
layoutVideo.add_widget(self.img2)
layoutVideo.add_widget(lb1)
layoutVideo.add_widget(lb2)
layoutVideo.add_widget(lb3)
layoutVideo.add_widget(lb4)
return layoutVideo
You have other errors in your code:
Error 1):
if __ name __ == "__ main __":
Principal().run()
They have spaces between __
and name
before and after, so does __ main __
. The correct would be without the spaces getting like this:
if __name__ == "__main__":
Principal().run()
Error 2):
In the build()
method at the end of each line has a comma, causing a tuple to be assigned to the variable containing the object and None, (<kivy.uix.label.Label object at 0x7ff7c5ae6660>,None)
.
The correct one:
def build(self):
lb1 = Label(text="Usuário: ",font_size= '15sp',size_hint= (None,None),pos_hint= {"center_x":.40, "center_y":.43},bold= True)
lb2 = Label(text="Senha: ",size_hint= (None,None),font_size= "15sp",pos_hint={"center_x":.40, "center_y":.36},bold= True)
lb3 = Label(text="Cadatre-se!",size_hint= (None, None),font_size= "8sp",pos_hint= {"center_x":.5, "center_y":.3},bold= True)
lb4 = Label(text="Esqueceu sua senha?",size_hint= (None, None),font_size= "8sp",pos_hint= {"center_x":.5, "center_y":.32},bold= True)
# o restante do codigo...
Tip: Give preference to create layouts in a separate .kv
file, leave the classes to create the "business rules".