Tartalomjegyzék

< KivyMD

KivyMD

Telepítés

pip3 install kivymd

Segítség

Kezdés

from kivymd.app import MDApp
 
class SimpleApp(MDApp):
    def build(self):
        return
 
SimpleApp().run()

Hello Világ

hello.py
from kivymd.app import MDApp
from kivymd.uix.label import MDLabel
 
 
class MainApp(MDApp):
    def build(self):
        return MDLabel(text="Helló Világ", halign="center")
 
MainApp().run()

Változat:

hello.py
from kivymd.app import MDApp
from kivymd.uix.label import MDLabel
 
class SimpleApp(MDApp):
    def build(self):
        label1 = MDLabel(text='Helló Világ')
        return label1
 
SimpleApp().run()

Színek

szin.py
from kivymd.app import MDApp
from kivymd.uix.label import MDLabel
 
class SimpleApp(MDApp):
    def build(self):
        label1 = MDLabel(
            text='Helló Világ',
            halign='center',
            theme_text_color='Error'
        )
        return label1
 
SimpleApp().run()
szinek.py
from kivymd.app import MDApp
from kivymd.uix.label import MDLabel
 
class SimpleApp(MDApp):
    def build(self):
        label1 = MDLabel(
            text='Helló Világ',
            halign='center',
            theme_text_color='Custom',
            text_color=(0, 0, 1, 1)
        )
        return label1
 
SimpleApp().run()

Decimális számokkal:

text_color=(80/255.0, 80/255.0, 80/255.0, 1)

Fontstílus:

label1 = MDLabel(
     text='Helló Világ',
     halign='center',
     theme_text_color='Custom',
     text_color=(0, 0, 1, 1),
     font_style='H1'
)

MDIkon

ikon.py
from kivymd.app import MDApp
from kivymd.uix.label import MDIcon
 
class SimpleApp(MDApp):
    def build(self):
        icon_label = MDIcon(icon='account-circle', halign='center')
        return icon_label
 
SimpleApp().run()

Nyomógomb

gomb.py
from kivymd.app import MDApp
from kivymd.uix.screen import Screen
from kivymd.uix.button import MDFlatButton
 
class SimpleApp(MDApp):
    def build(self):
        screen = Screen()
        btn_flat = MDFlatButton(text='Mehet')
        screen.add_widget(btn_flat)
        return screen
 
SimpleApp().run()

Igazítás:

        btn_flat = MDFlatButton(text='Mehet',
            pos_hint={'center_x': 0.5, 'center_y': 0.5})
from kivymd.app import MDApp
from kivymd.uix.screen import Screen
from kivymd.uix.button import MDRectangleFlatButton
 
class SimpleApp(MDApp):
    def build(self):
        screen = Screen()
        btn_flat = MDRectangleFlatButton(text='Mehet',
            pos_hint={'center_x': 0.5, 'center_y': 0.5})
        screen.add_widget(btn_flat)
        return screen
 
SimpleApp().run()

Ikonos gomb:

Ikonok:

ikonos.py
from kivymd.app import MDApp
from kivymd.uix.screen import Screen
from kivymd.uix.button import MDIconButton
 
class SimpleApp(MDApp):
    def build(self):
        screen = Screen()
        btn_flat = MDIconButton(icon='account-circle',
            pos_hint={'center_x': 0.5, 'center_y': 0.5})
        screen.add_widget(btn_flat)
        return screen
 
SimpleApp().run()

Lebegő gomb:

lebego.py
from kivymd.app import MDApp
from kivymd.uix.screen import Screen
from kivymd.uix.button import MDFloatingActionButton
 
class SimpleApp(MDApp):
    def build(self):
        screen = Screen()
        btn_flat = MDFloatingActionButton(icon='account-circle',
            pos_hint={'center_x': 0.5, 'center_y': 0.5})
        screen.add_widget(btn_flat)
        return screen
 
SimpleApp().run()