Material App#
#
This module contains MDApp
class that is inherited from
App
. MDApp
has some properties needed for KivyMD
library (like theme_cls
). You can turn on the monitor
displaying the current FP value in your application:
KV = '''
MDScreen:
md_bg_color: self.theme_cls.backgroundColor
MDLabel:
text: "Hello, World!"
halign: "center"
'''
from kivy.lang import Builder
from kivymd.app import MDApp
class MainApp(MDApp):
def build(self):
return Builder.load_string(KV)
def on_start(self):
super().on_start()
self.fps_monitor_start()
MainApp().run()
Note
Note that if you override the built-in on_start method, you will definitely need to call the super method:
class MainApp(MDApp):
def build(self):
[...]
def on_start(self):
super().on_start()
[...]
API - kivymd.app
#
- class kivymd.app.MDApp(**kwargs)#
Application class, see
App
class documentation for more information.- icon#
See
icon
attribute for more information.New in version 1.1.0.
icon
is anStringProperty
adn default to kivymd/images/logo/kivymd-icon-512.png.
- theme_cls#
Instance of
ThemeManager
class.Warning
The
theme_cls
attribute is already available in a class that is inherited from theMDApp
class. The following code will result in an error!class MainApp(MDApp): theme_cls = ThemeManager() theme_cls.primary_palette = "Teal"
Note
Correctly do as shown below!
class MainApp(MDApp): def build(self): self.theme_cls.primary_palette = "Teal"
theme_cls
is anObjectProperty
.
- on_start()#
Event handler for the on_start event which is fired after initialization (after build() has been called) but before the application has started running.
New in version 2.0.0.