title: How to select widgets by class name like in CSS in Kivy?
body: <p>For example I want to put a background color to all the buttons in the application :</p>
  <pre><code>&lt;Layout1&gt;:
      &lt;BoxLayout&gt;:
          &lt;Button&gt;:
              text: &quot;btn 1&quot;
          &lt;Button&gt;:
              text: &quot;btn 2&quot;
          &lt;Button&gt;:
              text: &quot;btn 3&quot;
      &lt;Button&gt;:
          text: &quot;Another button outside the boxlayout&quot;
  
  &lt;Layout2&gt;:
      &lt;GridLayout&gt;:
          cols: 2
          &lt;Button&gt;:
              text: &quot;btn 1 in a grid&quot;
          &lt;Button&gt;:
              text: &quot;btn 2 in a grid&quot;
  </code></pre>
  <p>But I don't want to do that by hand for all of them like this :</p>
  <pre><code>...
      &lt;Button&gt;:
          text: &quot;btn 1&quot;
          background_color: (1, 0, 0, 1)
      &lt;Button&gt;:
          text: &quot;btn 2&quot;
          background_color: (1, 0, 0, 1)
      &lt;Button&gt;:
          text: &quot;btn 3&quot;
          background_color: (1, 0, 0, 1)
  ...
  </code></pre>
  <p>So I'm looking for a shorter way like if we can put a class like in CSS to all of the buttons and access them by the class name. Something like that :</p>
  <pre><code>...
      &lt;Button&gt;:
          text: &quot;btn 1&quot;
          class: &quot;btn_class&quot;
      &lt;Button&gt;:
          text: &quot;btn 2&quot;
          class: &quot;btn_class&quot;
      &lt;Button&gt;:
          text: &quot;btn 3&quot;
          class: &quot;btn_class&quot;
  ...
  </code></pre>
  <p>And in python code :</p>
  <pre><code>for btn in get_widgets_by_classname(&quot;btn_class&quot;) :
      btn.background_color = (1, 0, 0, 1)
  </code></pre>
  <p>In the documentation <a href="https://kivy.org/doc/stable/api-kivy.lang.html#overview" rel="nofollow noreferrer">https://kivy.org/doc/stable/api-kivy.lang.html#overview</a> it says :</p>
  <blockquote>
  <p>You can target a specific class of widgets (similar to the CSS concept
  of a class) by using the cls attribute (e.g. cls=MyTestWidget)</p>
  </blockquote>
  <p>but it's not that clear for me about the use of the cls attribute.</p>