def build(self): root = Builder.load_string(kitchen_sink_kv) root.toolbar.nav_button = ["md-menu", lambda *x: root.nav.toggle()] root.toolbar.add_action_button("md-refresh") root.toolbar.add_action_button("md-more-vert") root.r_btn_1.bind(on_release=lambda *x: setattr(root.dialog_btn, 'disabled', not root.dialog_btn.disabled)) self.tile_data = [{'text': "Button 1", 'secondary_text': "With a secondary text"}, {'text': "Button 2", 'secondary_text': "With a secondary text"}, {'text': "Button 3", 'secondary_text': "With a secondary text"}, {'text': "Button 4", 'secondary_text': "With a secondary text"}] self.tile_single_data = [{'text': "Button 1"}, {'text': "Button 2"}, {'text': "Button 3"}, {'text': "Button 4"}] self.tile_icon_data = [{'icon': 'md-alarm', 'text': 'Alarm', 'secondary_text': "An alarm button", 'callback': root.nav.dismiss}, {'icon': 'md-event', 'text': 'Event', 'secondary_text': "An event button", 'callback': root.nav.dismiss}, {'icon': 'md-search', 'text': 'Search', 'secondary_text': "A search button", 'callback': root.nav.dismiss}, {'icon': 'md-thumb-up', 'text': 'Like', 'secondary_text': "A like button", 'callback': root.nav.dismiss}] self.tile_avatar_data = [{'avatar': images_path + 'default_avatar.jpg', 'text': 'Avatar tile', 'secondary_text': "That's a handsome dude!"}, {'avatar': images_path + 'default_avatar.jpg', 'text': 'Avatar tile', 'secondary_text': "Very handsome indeed"}, {'avatar': images_path + 'default_avatar.jpg', 'text': 'Avatar tile', 'secondary_text': "Extraordinary handsome"}, {'avatar': images_path + 'default_avatar.jpg', 'text': 'Avatar tile', 'secondary_text': "Super handsome"}] content = MaterialLabel(font_style='Body1', theme_text_color='Secondary', text="This is a Dialog with a title and some text. That's pretty awesome right!", valign='top') content.bind(size=content.setter('text_size')) self.dialog = Dialog(title="This is a test dialog", content=content, size_hint=(.8, None), height=dp(200), auto_dismiss=True) self.dialog.add_action_button("Dismiss", action=lambda *x: self.dialog.dismiss()) root.textfield.bind(on_text_validate=self.set_error_message, on_focus=self.set_error_message) root.dialog_btn.bind(on_release=self.dialog.open) return root
def build(self): root = Builder.load_string(kitchen_sink_kv) root.toolbar.nav_button = ["md-menu", lambda *x: root.nav.toggle()] root.toolbar.add_action_button("md-refresh") root.toolbar.add_action_button("md-more-vert") root.r_btn_1.bind(on_release=lambda *x: setattr( root.dialog_btn, 'disabled', not root.dialog_btn.disabled)) self.tile_data = [{ 'text': "Button 1", 'secondary_text': "With a secondary text" }, { 'text': "Button 2", 'secondary_text': "With a secondary text" }, { 'text': "Button 3", 'secondary_text': "With a secondary text" }, { 'text': "Button 4", 'secondary_text': "With a secondary text" }] self.tile_single_data = [{ 'text': "Button 1" }, { 'text': "Button 2" }, { 'text': "Button 3" }, { 'text': "Button 4" }] self.tile_icon_data = [{ 'icon': 'md-alarm', 'text': 'Alarm', 'secondary_text': "An alarm button", 'callback': root.nav.dismiss }, { 'icon': 'md-event', 'text': 'Event', 'secondary_text': "An event button", 'callback': root.nav.dismiss }, { 'icon': 'md-search', 'text': 'Search', 'secondary_text': "A search button", 'callback': root.nav.dismiss }, { 'icon': 'md-thumb-up', 'text': 'Like', 'secondary_text': "A like button", 'callback': root.nav.dismiss }] self.tile_avatar_data = [{ 'avatar': images_path + 'default_avatar.jpg', 'text': 'Avatar tile', 'secondary_text': "That's a handsome dude!" }, { 'avatar': images_path + 'default_avatar.jpg', 'text': 'Avatar tile', 'secondary_text': "Very handsome indeed" }, { 'avatar': images_path + 'default_avatar.jpg', 'text': 'Avatar tile', 'secondary_text': "Extraordinary handsome" }, { 'avatar': images_path + 'default_avatar.jpg', 'text': 'Avatar tile', 'secondary_text': "Super handsome" }] content = MaterialLabel( font_style='Body1', theme_text_color='Secondary', text= "This is a Dialog with a title and some text. That's pretty awesome right!", valign='top') content.bind(size=content.setter('text_size')) self.dialog = Dialog(title="This is a test dialog", content=content, size_hint=(.8, None), height=dp(200), auto_dismiss=True) self.dialog.add_action_button("Dismiss", action=lambda *x: self.dialog.dismiss()) root.textfield.bind(on_text_validate=self.set_error_message, on_focus=self.set_error_message) root.dialog_btn.bind(on_release=self.dialog.open) return root
class KitchenSink(App): theme_cls = ThemeManager() tile_data = ListProperty([]) tile_single_data = ListProperty([]) tile_icon_data = ListProperty() tile_avatar_data = ListProperty() nav = ObjectProperty() def __init__(self, **kwargs): super(KitchenSink, self).__init__(**kwargs) self.theme_cls.primary_palette = 'Green' self.theme_cls.accent_palette = 'Teal' self.theme_cls.theme_style = 'Light' def on_start(self): pass def build(self): root = Builder.load_string(kitchen_sink_kv) root.toolbar.nav_button = ["md-menu", lambda *x: root.nav.toggle()] root.toolbar.add_action_button("md-refresh") root.toolbar.add_action_button("md-more-vert") root.r_btn_1.bind(on_release=lambda *x: setattr(root.dialog_btn, 'disabled', not root.dialog_btn.disabled)) self.tile_data = [{'text': "Button 1", 'secondary_text': "With a secondary text"}, {'text': "Button 2", 'secondary_text': "With a secondary text"}, {'text': "Button 3", 'secondary_text': "With a secondary text"}, {'text': "Button 4", 'secondary_text': "With a secondary text"}] self.tile_single_data = [{'text': "Button 1"}, {'text': "Button 2"}, {'text': "Button 3"}, {'text': "Button 4"}] self.tile_icon_data = [{'icon': 'md-alarm', 'text': 'Alarm', 'secondary_text': "An alarm button", 'callback': root.nav.dismiss}, {'icon': 'md-event', 'text': 'Event', 'secondary_text': "An event button", 'callback': root.nav.dismiss}, {'icon': 'md-search', 'text': 'Search', 'secondary_text': "A search button", 'callback': root.nav.dismiss}, {'icon': 'md-thumb-up', 'text': 'Like', 'secondary_text': "A like button", 'callback': root.nav.dismiss}] self.tile_avatar_data = [{'avatar': images_path + 'default_avatar.jpg', 'text': 'Avatar tile', 'secondary_text': "That's a handsome dude!"}, {'avatar': images_path + 'default_avatar.jpg', 'text': 'Avatar tile', 'secondary_text': "Very handsome indeed"}, {'avatar': images_path + 'default_avatar.jpg', 'text': 'Avatar tile', 'secondary_text': "Extraordinary handsome"}, {'avatar': images_path + 'default_avatar.jpg', 'text': 'Avatar tile', 'secondary_text': "Super handsome"}] content = MaterialLabel(font_style='Body1', theme_text_color='Secondary', text="This is a Dialog with a title and some text. That's pretty awesome right!", valign='top') content.bind(size=content.setter('text_size')) self.dialog = Dialog(title="This is a test dialog", content=content, size_hint=(.8, None), height=dp(200), auto_dismiss=True) self.dialog.add_action_button("Dismiss", action=lambda *x: self.dialog.dismiss()) root.textfield.bind(on_text_validate=self.set_error_message, on_focus=self.set_error_message) root.dialog_btn.bind(on_release=self.dialog.open) return root def set_error_message(self, *args): if len(self.root.textfield.text) == 0: self.root.textfield.error = True self.root.textfield.error_message = "Some text is required" else: self.root.textfield.error = False def on_pause(self): return True def on_stop(self): pass
class KitchenSink(App): theme_cls = ThemeManager() tile_data = ListProperty([]) tile_single_data = ListProperty([]) tile_icon_data = ListProperty() tile_avatar_data = ListProperty() nav = ObjectProperty() def __init__(self, **kwargs): super(KitchenSink, self).__init__(**kwargs) self.theme_cls.primary_palette = 'Green' self.theme_cls.accent_palette = 'Teal' self.theme_cls.theme_style = 'Light' def on_start(self): pass def build(self): root = Builder.load_string(kitchen_sink_kv) root.toolbar.nav_button = ["md-menu", lambda *x: root.nav.toggle()] root.toolbar.add_action_button("md-refresh") root.toolbar.add_action_button("md-more-vert") root.r_btn_1.bind(on_release=lambda *x: setattr( root.dialog_btn, 'disabled', not root.dialog_btn.disabled)) self.tile_data = [{ 'text': "Button 1", 'secondary_text': "With a secondary text" }, { 'text': "Button 2", 'secondary_text': "With a secondary text" }, { 'text': "Button 3", 'secondary_text': "With a secondary text" }, { 'text': "Button 4", 'secondary_text': "With a secondary text" }] self.tile_single_data = [{ 'text': "Button 1" }, { 'text': "Button 2" }, { 'text': "Button 3" }, { 'text': "Button 4" }] self.tile_icon_data = [{ 'icon': 'md-alarm', 'text': 'Alarm', 'secondary_text': "An alarm button", 'callback': root.nav.dismiss }, { 'icon': 'md-event', 'text': 'Event', 'secondary_text': "An event button", 'callback': root.nav.dismiss }, { 'icon': 'md-search', 'text': 'Search', 'secondary_text': "A search button", 'callback': root.nav.dismiss }, { 'icon': 'md-thumb-up', 'text': 'Like', 'secondary_text': "A like button", 'callback': root.nav.dismiss }] self.tile_avatar_data = [{ 'avatar': images_path + 'default_avatar.jpg', 'text': 'Avatar tile', 'secondary_text': "That's a handsome dude!" }, { 'avatar': images_path + 'default_avatar.jpg', 'text': 'Avatar tile', 'secondary_text': "Very handsome indeed" }, { 'avatar': images_path + 'default_avatar.jpg', 'text': 'Avatar tile', 'secondary_text': "Extraordinary handsome" }, { 'avatar': images_path + 'default_avatar.jpg', 'text': 'Avatar tile', 'secondary_text': "Super handsome" }] content = MaterialLabel( font_style='Body1', theme_text_color='Secondary', text= "This is a Dialog with a title and some text. That's pretty awesome right!", valign='top') content.bind(size=content.setter('text_size')) self.dialog = Dialog(title="This is a test dialog", content=content, size_hint=(.8, None), height=dp(200), auto_dismiss=True) self.dialog.add_action_button("Dismiss", action=lambda *x: self.dialog.dismiss()) root.textfield.bind(on_text_validate=self.set_error_message, on_focus=self.set_error_message) root.dialog_btn.bind(on_release=self.dialog.open) return root def set_error_message(self, *args): if len(self.root.textfield.text) == 0: self.root.textfield.error = True self.root.textfield.error_message = "Some text is required" else: self.root.textfield.error = False def on_pause(self): return True def on_stop(self): pass