CircularLayout

CircularLayout is a special layout that places widgets around a circle.

MDCircularLayout

Usage

from kivy.lang.builder import Builder
from kivy.uix.label import Label

from kivymd.app import MDApp

kv = '''
MDScreen:

    MDCircularLayout:
        id: container
        pos_hint: {"center_x": .5, "center_y": .5}
        row_spacing: min(self.size) * 0.1
'''


class Main(MDApp):
    def build(self):
        return Builder.load_string(kv)

    def on_start(self):
        for x in range(1, 49):
            self.root.ids.container.add_widget(
                Label(text=f"{x}", color=[0, 0, 0, 1])
            )


Main().run()
https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/circular-layout.png

API - kivymd.uix.circularlayout

class kivymd.uix.circularlayout.MDCircularLayout(**kwargs)

Float layout class. See module documentation for more information.

degree_spacing

The space between children in degree.

degree_spacing is an NumericProperty and defaults to 30.

circular_radius

Radius of circle. Radius will be the greatest value in the layout if circular_radius if not specified.

circular_radius is an NumericProperty and defaults to None.

start_from

The positon of first child in degree.

start_from is an NumericProperty and defaults to 60.

max_degree

Maximum range in degree allowed for each row of widgets before jumping to the next row.

max_degree is an NumericProperty and defaults to 360.

circular_padding

Padding between outer widgets and the edge of the biggest circle.

circular_padding is an NumericProperty and defaults to 25dp.

row_spacing

Space between each row of widget.

row_spacing is an NumericProperty and defaults to 50dp.

clockwise

Direction of widgets in circular direction.

clockwise is an BooleanProperty and defaults to True.

get_angle(self, pos: tuple)

Returns the angle of given pos.

remove_widget(self, widget, **kwargs)

Remove a widget from the children of this widget.

Parameters
widget: Widget

Widget to remove from our children list.

>>> from kivy.uix.button import Button
>>> root = Widget()
>>> button = Button()
>>> root.add_widget(button)
>>> root.remove_widget(button)
do_layout(self, *largs, **kwargs)

This function is called when a layout is called by a trigger. If you are writing a new Layout subclass, don’t call this function directly but use _trigger_layout() instead.

The function is by default called before the next frame, therefore the layout isn’t updated immediately. Anything depending on the positions of e.g. children should be scheduled for the next frame.

New in version 1.0.8.