kivymd code example
Example: kivymd
from kivy.lang import Builder
from kivy.properties import ObjectProperty
from kivymd.app import MDApp
from kivymd.uix.floatlayout import MDFloatLayout
from kivymd.uix.tab import MDTabsBase
from kivymd.icon_definitions import md_icons
colors = {
"Teal": {
"50": "e4f8f9",
"100": "bdedf0",
"200": "97e2e8",
"300": "79d5de",
"400": "6dcbd6",
"500": "6ac2cf",
"600": "63b2bc",
"700": "5b9ca3",
"800": "54888c",
"900": "486363",
"A100": "bdedf0",
"A200": "97e2e8",
"A400": "6dcbd6",
"A700": "5b9ca3",
},
"Blue": {
"50": "e3f3f8",
"100": "b9e1ee",
"200": "91cee3",
"300": "72bad6",
"400": "62acce",
"500": "589fc6",
"600": "5191b8",
"700": "487fa5",
"800": "426f91",
"900": "35506d",
"A100": "b9e1ee",
"A200": "91cee3",
"A400": "62acce",
"A700": "487fa5",
},
"Light": {
"StatusBar": "E0E0E0",
"AppBar": "F5F5F5",
"Background": "FAFAFA",
"CardsDialogs": "FFFFFF",
"FlatButtonDown": "cccccc",
},
"Dark": {
"StatusBar": "000000",
"AppBar": "212121",
"Background": "303030",
"CardsDialogs": "424242",
"FlatButtonDown": "999999",
}
}
KV = '''
BoxLayout:
orientation: "vertical"
MDToolbar:
title: "Example Tabs"
MDTabs:
id: tabs
<Tab>
MDIconButton:
id: icon
icon: root.icon
user_font_size: "48sp"
pos_hint: {"center_x": .5, "center_y": .5}
'''
class Tab(MDFloatLayout, MDTabsBase):
'''Class implementing content for a tab.'''
icon = ObjectProperty()
class Example(MDApp):
icons = list(md_icons.keys())[15:30]
def build(self):
self.theme_cls.colors = colors
self.theme_cls.primary_palette = "Blue"
self.theme_cls.accent_palette = "Teal"
return Builder.load_string(KV)
def on_start(self):
for name_tab in self.icons:
tab = Tab(text="This is " + name_tab, icon=name_tab)
self.root.ids.tabs.add_widget(tab)
Example().run()