:github_url: https://github.com/kivymd/KivyMD/blob/master/kivymd/uix/circularlayout.py

CircularLayout
==============

.. py:module:: kivymd.uix.circularlayout

.. autoapi-nested-parse::

   Components/CircularLayout
   =========================

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

   MDCircularLayout
   ----------------

   .. rubric:: Usage

   .. tabs::

       .. tab:: Imperative python style with KV

           .. code-block:: python

               from kivy.lang.builder import Builder

               from kivymd.app import MDApp
               from kivymd.uix.label import MDLabel

               KV = '''
               MDScreen:
                   md_bg_color: self.theme_cls.backgroundColor

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


               class Example(MDApp):
                   def build(self):
                       self.theme_cls.theme_style = "Dark"
                       return Builder.load_string(KV)

                   def on_start(self):
                       for x in range(1, 49):
                           self.root.ids.container.add_widget(
                               MDLabel(text=f"{x}", adaptive_size=True)
                           )


               Example().run()

       .. tab:: Declarative python style

           .. code-block:: python

               from kivy.clock import Clock

               from kivymd.app import MDApp
               from kivymd.uix.circularlayout import MDCircularLayout
               from kivymd.uix.label import MDLabel
               from kivymd.uix.screen import MDScreen


               class Example(MDApp):
                   def build(self):
                       self.theme_cls.theme_style = "Dark"
                       self.screen = MDScreen(
                           MDCircularLayout(
                               id="container",
                               pos_hint={"center_x": 0.5, "center_y": 0.5},
                           ),
                           md_bg_color=self.theme_cls.backgroundColor
                       )
                       return self.screen

                   def on_start(self):
                       def on_start(*args):
                           container.row_spacing = min(container.size) * 0.1

                       container = self.screen.get_ids().container
                       for x in range(1, 49):
                           self.screen.get_ids().container.add_widget(
                               MDLabel(text=f"{x}", adaptive_size=True)
                           )

                       Clock.schedule_once(on_start)


               Example().run()

   .. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/circular-layout.png
       :align: center


API - :mod:`kivymd.uix.circularlayout`
--------------------------------------

.. py:class:: MDCircularLayout(*args, **kwargs)




   Circular layout class.

   For more information see in the
   :class:`~kivymd.uix.behaviors.declarative_behavior.DeclarativeBehavior` and
   :class:`~kivy.uix.floatlayout.FloatLayout`
   classes documentation.

   .. py:attribute:: degree_spacing

      The space between children in degree.

      :attr:`degree_spacing` is an :class:`~kivy.properties.NumericProperty`
      and defaults to `30`.


   .. py:attribute:: circular_radius

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

      :attr:`circular_radius` is an :class:`~kivy.properties.NumericProperty`
      and defaults to `None`.


   .. py:attribute:: start_from

      The positon of first child in degree.

      :attr:`start_from` is an :class:`~kivy.properties.NumericProperty`
      and defaults to `60`.


   .. py:attribute:: max_degree

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

      :attr:`max_degree` is an :class:`~kivy.properties.NumericProperty`
      and defaults to `360`.


   .. py:attribute:: circular_padding

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

      :attr:`circular_padding` is an :class:`~kivy.properties.NumericProperty`
      and defaults to `25dp`.


   .. py:attribute:: row_spacing

      Space between each row of widget.

      :attr:`row_spacing` is an :class:`~kivy.properties.NumericProperty`
      and defaults to `50dp`.


   .. py:attribute:: clockwise

      Direction of widgets in circular direction.

      :attr:`clockwise` is an :class:`~kivy.properties.BooleanProperty`
      and defaults to `True`.


   .. py:method:: get_angle(pos: tuple) -> float

      Returns the angle of given pos.


   .. py:method:: remove_widget(widget, **kwargs)

      Remove a widget from the children of this widget.

          :Parameters:
              `widget`: :class:`Widget`
                  Widget to remove from our children list.

      .. code-block:: python

          >>> from kivy.uix.button import Button
          >>> root = Widget()
          >>> button = Button()
          >>> root.add_widget(button)
          >>> root.remove_widget(button)
          


   .. py:method:: do_layout(*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 :meth:`_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.

      .. versionadded:: 1.0.8




