As commented by Anderson python is case-sensitive (case-sensitive), and according to the kivy documentation the method build()
is in low (lower case). To correct just replace Build()
for build()
Earlier 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()
for 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
There are other errors in your code:
Error 1):
if __ name __ == "__ main __":
Principal().run()
Are with spaces between __
and name
before and after, the same occurs in __ main __
. The right thing would be without the spaces being like this:
if __name__ == "__main__":
Principal().run()
Error 2):
In the method build()
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)
.
Right:
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 creating layouts in a file .kv
separate, leave the classes to create the "business rules".
Maybe because you created the method
Build
and Kivy is waitingbuild
, with tiny b? Remember that Python is case-sensitive, then the two words are not equal.– Woss