title: Display Kivy canvas inside GridLayout
body: <p>I am trying to reference to Canvas within GridLayout with just drawing simple rectangle before further development.
  Code:</p>
  <p>main.py:</p>
  <pre><code>import kivy
  from kivy.app import App
  from kivy.uix.widget import Widget
  from kivy.lang import Builder
  from kivy.graphics.vertex_instructions import Rectangle
  from kivy.graphics.context_instructions import Color
  
  class Grafika(Widget):
      def __init__(self, **kwargs):
          super(Grafika,self).__init__(**kwargs)
          with self.canvas:
              Color(1, 0, 0, 1)
              Rectangle(pos=self.pos,size=self.size)
  
  kv=Builder.load_file(&quot;my.kv&quot;)
  
  class MyMainApp(App):
      def build(self):
          return kv
  
  if __name__ == &quot;__main__&quot;:
      MyMainApp().run()
  </code></pre>
  <p>my.py</p>
  <pre><code>&lt;TextInput&gt;:
      font_size:20
      color: 0.3, 0.6,0.7,1
      size_hint: (0.3,0.5)
  &lt;Button&gt;:
      font_size:20
      color: 0.3, 0.6,0.7,1
      size_hint: (0.3,0.3)
  
  
  Grafika:
      GridLayout:
          cols:2
          GridLayout:
              size_hint: (0.3,0.2)
              cols:1
              GridLayout:
                  cols:2
                  Label:
                      text:&quot;no&quot;
                  TextInput:
                      text: &quot;50&quot;
                  Label:
                      text:&quot;rbr&quot;
                  TextInput:
                      text: &quot;100&quot;
              Button:
                  text:&quot;calc&quot;
          canvas:
              Color:
                  rbg:1, 1, 1, 1
              Rectangle:
                  pos:self.pos
                  size:self.size
  </code></pre>
  <p>After running i get error:</p>
  <pre><code>...
       27:            Button:
       28:                text:&quot;calc&quot;
  &gt;&gt;   29:        canvas:
       30:            Color:
       31:                rbg:1, 1, 1, 1
  ...
  Canvas instructions added in kv must be declared before child widgets.
  </code></pre>
  <p>I am new in kivy, so any help is appreciated.</p>
  <p>After solving this issue, I am planning to run custom python func , run under button calc, and return calculated results on canvas.
  Func results are 2d line points, hence plotting of results on canvas is goal here.</p>