Fit Image

Feature to automatically crop a Kivy image to fit your layout Write by Benedikt Zwölfer

Referene - https://gist.github.com/benni12er/95a45eb168fc33a4fcd2d545af692dad

Example:

BoxLayout:

size_hint_y: None height: dp(200) orientation: ‘vertical’

FitImage:

size_hint_y: 3 source: ‘images/img1.jpg’

FitImage:

size_hint_y: 1 source: ‘images/img2.jpg’

API - kivymd.utils.fitimage

class kivymd.utils.fitimage.FitImage(**kwargs)

Box layout class. See module documentation for more information.

source
class kivymd.utils.fitimage.Container(source, **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 subclassing Widget.

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.

adjust_size(self, *args)