Home > Back-end >  Kivy running but no content shown on GUI
Kivy running but no content shown on GUI

Time:12-27

I'm trying to learn about kivy and mobile app, however after creating a simple code base on the tutorial, the content/s is not showing on the gui.

Pls see image below:

enter image description here

I was able to install the kivy pip after knowing that it is only supported at 3.7-3.10. Installed tkinter and ffpyplayer also upgraded sdl2 but still not showing content

enter image description here

import kivy
from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button

class childApp(GridLayout):
    def __int__(self,**kwargs):
        super(childApp, self).__init__()
        self.cols = 2
        self.add_widget(Label(text = 'Student Name'))
        self.s_name = TextInput( )
        self.add_widget(self.s_name)
    
        self.add_widget(Label(text = 'Student Marks'))
        self.s_marks = TextInput( )
        self.add_widget(self.s_marks)

        self.add_widget(Label(text = 'Student Gender'))
        self.s_gender = TextInput( )
        self.add_widget(self.s_gender)

class parentApp(App):
    def build(self):
        return childApp()

if __name__ == "__main__":
    parentApp().run()

CodePudding user response:

You made a simple typo in childApp class. it should be __init__ not __int__

from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button

class childApp(GridLayout):
    def __init__(self,**kwargs):
        super(childApp, self).__init__()
        self.cols = 2
        self.add_widget(Label(text = 'Student Name'))
        self.s_name = TextInput( )
        self.add_widget(self.s_name)
        
        self.add_widget(Label(text = 'Student Marks'))
        self.s_marks = TextInput( )
        self.add_widget(self.s_marks)

        self.add_widget(Label(text = 'Student Gender'))
        self.s_gender = TextInput( )
        self.add_widget(self.s_gender)

class parentApp(App):
    def build(self):
        return childApp()

if __name__ == "__main__":
    parentApp().run()

  • Related