Background Color¶
Note
The following classes are intended for in-house use of the library.
API - kivymd.uix.behaviors.backgroundcolorbehavior
¶
-
class
kivymd.uix.behaviors.backgroundcolorbehavior.
BackgroundColorBehavior
(**kwargs)¶ Widget class. See module documentation for more information.
- Events
- on_touch_down: (touch, )
Fired when a new touch event occurs. touch is the touch object.
- on_touch_move: (touch, )
Fired when an existing touch moves. touch is the touch object.
- on_touch_up: (touch, )
Fired when an existing touch disappears. touch is the touch object.
- on_kv_post: (base_widget, )
Fired after all the kv rules associated with the widget and all other widgets that are in any of those rules have had all their kv rules applied. base_widget is the base-most widget whose instantiation triggered the kv rules (i.e. the widget instantiated from Python, e.g.
MyWidget()
).Changed in version 1.11.0.
Warning
Adding a __del__ method to a class derived from Widget with Python prior to 3.4 will disable automatic garbage collection for instances of that class. This is because the Widget class creates reference cycles, thereby preventing garbage collection.
Changed in version 1.0.9: Everything related to event properties has been moved to the
EventDispatcher
. Event properties can now be used when contructing a simple class without subclassingWidget
.Changed in version 1.5.0: The constructor now accepts on_* arguments to automatically bind callbacks to properties or events, as in the Kv language.
-
r
¶ The value of
red
in thergba
palette.r
is anBoundedNumericProperty
and defaults to 1.0.
-
g
¶ The value of
green
in thergba
palette.g
is anBoundedNumericProperty
and defaults to 1.0.
-
b
¶ The value of
blue
in thergba
palette.b
is anBoundedNumericProperty
and defaults to 1.0.
-
a
¶ The value of
alpha channel
in thergba
palette.a
is anBoundedNumericProperty
and defaults to 0.0.
-
radius
¶ Canvas radius.
# Top left corner slice. MDBoxLayout: md_bg_color: app.theme_cls.primary_color radius: [25, 0, 0, 0]
radius
is anListProperty
and defaults to [0, 0, 0, 0].
-
md_bg_color
¶ The background color of the widget (
Widget
) that will be inherited from theBackgroundColorBehavior
class.For example:
Widget: canvas: Color: rgba: 0, 1, 1, 1 Rectangle: size: self.size pos: self.pos
similar to code:
<MyWidget@BackgroundColorBehavior> md_bg_color: 0, 1, 1, 1
md_bg_color
is anReferenceListProperty
and defaults tor
,g
,b
,a
.
-
class
kivymd.uix.behaviors.backgroundcolorbehavior.
SpecificBackgroundColorBehavior
(**kwargs)¶ Widget class. See module documentation for more information.
- Events
- on_touch_down: (touch, )
Fired when a new touch event occurs. touch is the touch object.
- on_touch_move: (touch, )
Fired when an existing touch moves. touch is the touch object.
- on_touch_up: (touch, )
Fired when an existing touch disappears. touch is the touch object.
- on_kv_post: (base_widget, )
Fired after all the kv rules associated with the widget and all other widgets that are in any of those rules have had all their kv rules applied. base_widget is the base-most widget whose instantiation triggered the kv rules (i.e. the widget instantiated from Python, e.g.
MyWidget()
).Changed in version 1.11.0.
Warning
Adding a __del__ method to a class derived from Widget with Python prior to 3.4 will disable automatic garbage collection for instances of that class. This is because the Widget class creates reference cycles, thereby preventing garbage collection.
Changed in version 1.0.9: Everything related to event properties has been moved to the
EventDispatcher
. Event properties can now be used when contructing a simple class without subclassingWidget
.Changed in version 1.5.0: The constructor now accepts on_* arguments to automatically bind callbacks to properties or events, as in the Kv language.
-
background_palette
¶ See
kivymd.color_definitions.palette
.background_palette
is anOptionProperty
and defaults to ‘Primary’.
-
background_hue
¶ See
kivymd.color_definitions.hue
.background_hue
is anOptionProperty
and defaults to ‘500’.
-
specific_text_color
¶ specific_text_color
is anListProperty
and defaults to [0, 0, 0, 0.87].
-
specific_secondary_text_color
¶ specific_secondary_text_color`is an :class:`~kivy.properties.ListProperty
and defaults to [0, 0, 0, 0.87].