Kivy: how to reference widgets from python code?
<p>Basic Kivy question. Given this kv file:</p>

<pre><code>BoxLayout:
    MainMenu:
    MyCanvasWidget:

&lt;MainMenu&gt;:
    Button:
        on_press: root.do_action()
</code></pre>

<p>How do I call a method of MyCanvasWidget (for drawing something) from the do_action method when the button in MainMenu is pressed?</p>

<pre><code>BoxLayout:
    MainMenu:
        do_action: mycanvas.method
    MyCanvasWidget:
        id: mycanvas

&lt;MainMenu&gt;:
    Button:
        on_press: root.do_action()
</code></pre>

<p>Got some inspiration from <a href="http://stackoverflow.com/questions/39807997/how-to-access-some-widget-attribute-from-another-widget-in-kivy?rq=1">How to access some widget attribute from another widget in Kivy?</a></p>

python python-2.7 kivy kivy-language