Python Forum
Help with code Kivy/Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with code Kivy/Python
#1
Hello everyone, I need a help, I do not understand why when I run the following code the screen appears only black. Can someone give me a hand?

I'm starting my first mobile software, I'm happy if you can help, thank you :D

from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.widget import Widget
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.image import Image
 
class Principal(App):
 
         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
 
if __name__ == "__main__":
Principal().run()
Reply
#2
Hello,
I'm kind of a kivy newb, but I saw a couple mistakes.
1 in the app class def build(self): (Not Build)
2 the commas after each widget needs to be deleted
example: self.img1 = Image(source= "images/Logo.jpg",size_hint= (.5, .3),pos_hint={"center_x":.5, "center_y":.9})
I was able to run it using other images good luck, Joe
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Kivy] 'Design' had no attribute 'add' Error in Python and Kivy yahucoder 2 3,057 May-20-2019, 02:32 PM
Last Post: yahucoder
  Python Kivy Emerogork 1 3,009 Mar-19-2018, 09:30 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020