Skip to content

Instantly share code, notes, and snippets.

@BhJaipal
Last active April 2, 2023 10:47
Show Gist options
  • Save BhJaipal/28c13abe09b180f1846a813ea1abca79 to your computer and use it in GitHub Desktop.
Save BhJaipal/28c13abe09b180f1846a813ea1abca79 to your computer and use it in GitHub Desktop.
Kivy Use

Kivy use

First import nessary things like

from kivy.lang import Builder
from kivymd.app import MDApp
from kivymd.uix.screen import MDScreen

now either enter kivy code in """ or import method

kvCode= """
MDScreen:
    MDLabel:
        text: "Hello World"
        pos: 50, 56
        md_bg_color: #bbb
"""
from kivymd.uix.label import MDLabel
kvCode= MDScreen(
    MDLabel(
        text="Hello World",
        pos=(50, 56),
        md_bg_color="#bbb"
    )
)

now create class by parameter MDApp or App

class MyApp(MDApp):
    def build(self):
        self.theme_cls.primary_palette= "red";
        self.theme_cls.theme_style= "light";
        return Builder.load_string(kvCode);

then run the execute the class by

MyApp().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment