Exemplo n.º 1
0
 def __init__(self, **kwargs):
     self._layout = MaterialBoxLayout
     self._title_layout = RelativeLayout()
     self._title_header = MaterialLabel()
     self._title_bg = Image()
     self._list = List()
     super(DetailView, self).__init__(**kwargs)
     self._layout.add_widget(self._title_layout)
     self._layout.add_widget(self.list)
Exemplo n.º 2
0
	def __init__(self, **kwargs):
		self._msg_label = MaterialLabel(font_style='Caption',
										theme_text_color='Error',
										halign='left',
										valign='middle')
		self._hint_lbl = MaterialLabel(font_style='Subhead',
									   halign='left',
									   valign='middle')
		super(SingleLineTextField, self).__init__(**kwargs)
		self.line_color_normal = self._theme_cls.divider_color()
		self.line_color_focus = self._theme_cls.primary_color
		self.error_color = self._theme_cls.error_color
		self._hint_txt_color = self._theme_cls.hint_text_color()
		self.hint_text_color = (1, 1, 1, 0)
		self.cursor_color = self._theme_cls.primary_color

		self.bind(error_message=self._set_msg,
				  hint_text=self._set_hint,
				  _hint_lbl_font_size=self._hint_lbl.setter('font_size'))
Exemplo n.º 3
0
    def __init__(self, **kwargs):
        self._msg_label = MaterialLabel(font_style='Caption',
                                        theme_text_color='Error',
                                        halign='left',
                                        valign='middle')
        self._hint_lbl = MaterialLabel(font_style='Subhead',
                                       halign='left',
                                       valign='middle')
        super(SingleLineTextField, self).__init__(**kwargs)
        self.line_color_normal = self._theme_cls.divider_color()
        self.line_color_focus = self._theme_cls.primary_color
        self.error_color = self._theme_cls.error_color
        self._hint_txt_color = self._theme_cls.hint_text_color()
        self.hint_text_color = (1, 1, 1, 0)
        self.cursor_color = self._theme_cls.primary_color

        self.bind(error_message=self._set_msg,
                  hint_text=self._set_hint,
                  _hint_lbl_font_size=self._hint_lbl.setter('font_size'))
Exemplo n.º 4
0
	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
Exemplo n.º 5
0
class SingleLineTextField(ThemeBehaviour, TextInput):

	error_message = StringProperty('')

	line_color_normal = ListProperty([])
	line_color_focus = ListProperty([])

	error_color = ListProperty([])

	error = BooleanProperty(False)

	_hint_txt_color = ListProperty()
	_hint_lbl = ObjectProperty()
	_hint_lbl_font_size = NumericProperty(sp(16))
	_hint_y = NumericProperty(dp(10))
	_msg_label = ObjectProperty()
	_line_width = NumericProperty(0)
	_hint_txt = StringProperty('')
	def __init__(self, **kwargs):
		self._msg_label = MaterialLabel(font_style='Caption',
										theme_text_color='Error',
										halign='left',
										valign='middle')
		self._hint_lbl = MaterialLabel(font_style='Subhead',
									   halign='left',
									   valign='middle')
		super(SingleLineTextField, self).__init__(**kwargs)
		self.line_color_normal = self._theme_cls.divider_color()
		self.line_color_focus = self._theme_cls.primary_color
		self.error_color = self._theme_cls.error_color
		self._hint_txt_color = self._theme_cls.hint_text_color()
		self.hint_text_color = (1, 1, 1, 0)
		self.cursor_color = self._theme_cls.primary_color

		self.bind(error_message=self._set_msg,
				  hint_text=self._set_hint,
				  _hint_lbl_font_size=self._hint_lbl.setter('font_size'))

	def on_hint_text_color(self, instance, color):
		self._hint_txt_color = self._theme_cls.hint_text_color()
		self.hint_text_color = (1, 1, 1, 0)

	def on_width(self, instance, width):
		self.anim = Animation(_line_width=width, duration=.2, t='out_quad')

	def on_pos(self, *args):
		self.hint_anim_in = Animation(_hint_y=dp(34), _hint_lbl_font_size=sp(12), duration=.2, t='out_quad')
		self.hint_anim_out = Animation(_hint_y=dp(10), _hint_lbl_font_size=sp(16), duration=.2, t='out_quad')

	def on_focus(self, *args):
		if self.focus:
			Animation.cancel_all(self, '_line_width', '_hint_y', '_hint_lbl_font_size')
			if len(self.text) == 0:
				self.hint_anim_in.start(self)
			if not self.error:
				self.anim.start(self)
		else:
			Animation.cancel_all(self, '_line_width', '_hint_y', '_hint_lbl_font_size')
			if len(self.text) == 0:
				self.hint_anim_out.start(self)
			if not self.error:
				self._line_width = 0

	def _set_hint(self, instance, text):
		self._hint_lbl.text = text
		self._hint_lbl.texture_update()

	def _set_msg(self, instance, text):
		self._msg_label.text = text
		self._msg_label.texture_update()
Exemplo n.º 6
0
class SingleLineTextField(ThemeBehaviour, TextInput):

    error_message = StringProperty('')

    line_color_normal = ListProperty([])
    line_color_focus = ListProperty([])

    error_color = ListProperty([])

    error = BooleanProperty(False)

    _hint_txt_color = ListProperty()
    _hint_lbl = ObjectProperty()
    _hint_lbl_font_size = NumericProperty(sp(16))
    _hint_y = NumericProperty(dp(10))
    _msg_label = ObjectProperty()
    _line_width = NumericProperty(0)
    _hint_txt = StringProperty('')

    def __init__(self, **kwargs):
        self._msg_label = MaterialLabel(font_style='Caption',
                                        theme_text_color='Error',
                                        halign='left',
                                        valign='middle')
        self._hint_lbl = MaterialLabel(font_style='Subhead',
                                       halign='left',
                                       valign='middle')
        super(SingleLineTextField, self).__init__(**kwargs)
        self.line_color_normal = self._theme_cls.divider_color()
        self.line_color_focus = self._theme_cls.primary_color
        self.error_color = self._theme_cls.error_color
        self._hint_txt_color = self._theme_cls.hint_text_color()
        self.hint_text_color = (1, 1, 1, 0)
        self.cursor_color = self._theme_cls.primary_color

        self.bind(error_message=self._set_msg,
                  hint_text=self._set_hint,
                  _hint_lbl_font_size=self._hint_lbl.setter('font_size'))

    def on_hint_text_color(self, instance, color):
        self._hint_txt_color = self._theme_cls.hint_text_color()
        self.hint_text_color = (1, 1, 1, 0)

    def on_width(self, instance, width):
        self.anim = Animation(_line_width=width, duration=.2, t='out_quad')

    def on_pos(self, *args):
        self.hint_anim_in = Animation(_hint_y=dp(34),
                                      _hint_lbl_font_size=sp(12),
                                      duration=.2,
                                      t='out_quad')
        self.hint_anim_out = Animation(_hint_y=dp(10),
                                       _hint_lbl_font_size=sp(16),
                                       duration=.2,
                                       t='out_quad')

    def on_focus(self, *args):
        if self.focus:
            Animation.cancel_all(self, '_line_width', '_hint_y',
                                 '_hint_lbl_font_size')
            if len(self.text) == 0:
                self.hint_anim_in.start(self)
            if not self.error:
                self.anim.start(self)
        else:
            Animation.cancel_all(self, '_line_width', '_hint_y',
                                 '_hint_lbl_font_size')
            if len(self.text) == 0:
                self.hint_anim_out.start(self)
            if not self.error:
                self._line_width = 0

    def _set_hint(self, instance, text):
        self._hint_lbl.text = text
        self._hint_lbl.texture_update()

    def _set_msg(self, instance, text):
        self._msg_label.text = text
        self._msg_label.texture_update()
Exemplo n.º 7
0
    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