Skip to main content

Kivy App Run Method

 Create An App

Now It is easy to create  simple kivy app 

1.  Sub-Classing the App Class 

2. Implemennting its build() function mathod so it returns a Widget instance the roon of app (the root of your app widget tree) 

3. Instantiating this class, and calling its run() method, run method is run the main app


The sample of small app


from kivy.app import App

from kivy.uix.gridlayout import GridLayout

from kivy.uix.label import Label

from kivy.uix.textinput import TextInput


class Loginscreen(GridLayout):

    def __init__(self,**kwargs):

        super(Loginscreen,self).__init__(**kwargs)

        self.cols = 2

        self.add_widget(Label(text="User Name"))

        self.username = TextInput(multiline=False)

        self.add_widget(self.username)

        self.add_widget(Label(text="Password"))

        self.password = TextInput(multiline=False,password=True)

        self.add_widget(self.password)

        

class MyApp(App):

    def build(self):

        return Loginscreen()

if __name__ == "__main__":

    MyApp().run()






Comments

Post a Comment