[[oktatas:programozás:python:kivymd|< KivyMD]]
====== KivyMD ======
* **Szerző:** Sallai András
* Copyright (c) 2020, Sallai András
* Licenc: [[https://creativecommons.org/licenses/by-sa/4.0/|CC BY-SA 4.0]]
* Web: https://szit.hu
===== Telepítés =====
pip3 install kivymd
===== Segítség =====
* https://kivymd.readthedocs.io/
===== Kezdés =====
from kivymd.app import MDApp
class SimpleApp(MDApp):
def build(self):
return
SimpleApp().run()
===== Hello Világ =====
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:
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 =====
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()
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'
)
* ‘H1’, ‘H2’, ‘H3’, ‘H4’, ‘H5’, ‘H6’
* ‘Subtitle1’, ‘Subtitle2’
* ‘Body1’, ‘Body2’, ‘Button’
* ‘Caption’, ‘Overline’, ‘Icon’
===== MDIkon =====
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 =====
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:
* https://github.com/kivymd/KivyMD/blob/master/kivymd/icon_definitions.py (2020)
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:
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()