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

Popular posts from this blog

Kivy Create First App

kivy is a open source python framework ,kivy run on Linux,Window,OS X, Android, iOS and Respberry Pi, You can run the same code on all supported platforms Now create first app using kivy frame work Step 1 : Install python on your operating system Download or install python for this link  https://www.python.org/downloads/ Step 2 : Install Kivy Framework Download or install kivy for this link  https://kivy.org/doc/stable/gettingstarted/installation.html  select the your operating system and install it Step 3 : Create first app code file main.py from kivy.app import App from kivy.uix.label import Label class MainApp(App):     def build(self):          return Label(text="Hello this is first app") if __name__ == "__main__":     MainApp().run() Step 4: Save the main.py file Step 5 : Open the terminal or cmd prompt  and set the main.py file path Step 6 : Enter the file name on terminal or cmd prompt python main.py  and...

How to install kivy on your operating system

Kivy latest versionis 2.0.0 officially supports python  versions 3.6 - 3.9 Now you can install kivy first of all you are notice the python is installed on your OS Step 1 : Open this link  https://kivy.org/doc/stable/gettingstarted/installation.html and select the OS install  make sure which is your operating system and than click links Step 2 : You can install kivy using pip  you simply type on your terminal/cmd : pip install kivy Kivy install in Window :  simply type on your  terminal/cmd   python -m pip install kivy   Kviy install in linux :  simply type on your  terminal   python3 - m pip install kivy Kivy install in OS X :  simply type on your  terminal  python - m pip install kivy Kivy install in RPi :  simply type on your  terminal/cmd   python -m pip install kivy Kivy install in  conda : conda install kivy - c conda - forge If  your  kivy  not instal...