title: How to return the bounding box for the (row, column) position of a canvas as a tuple of grid
body: <p>I am trying to write a code which will finally look like this:
  <a href="https://i.stack.imgur.com/lX0fV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lX0fV.png" alt="enter image description here" /></a></p>
  <p>Canvases are just a sea of pixels, so all I am trying to do is adding a little bit extra functionality
  to make navigating that sea easier. Later on I'll be drawing rectangles (well, squares) onto the
  canvas to represent the entities.</p>
  <p>To do that I need a top left and a bottom right pixel coordinate.
  So get_bbox allows translation from an instance of the Position(x,y) class (which is what we like to work
  with because its stored in our grids dictionary) to these pixel coordinates, allowing us to easily work with the canvas like its a grid.</p>
  <pre><code>
  class AbstractGrid(tk.Canvas):
      
      def __init__(self, master, rows, cols, width, height, **kwargs):
          &quot;&quot;&quot;
  
          master: The window in which the grid should be drawn. 
          rows: The integer number of rows in the grid.
          cols: The integer number of columns in the grid.
          width: The width of the grid canvas (in pixels). 
          height: The height of the grid canvas (in pixels). 
          **kwargs: Any other additional named parameters appropriate to tk.Canvas.
          &quot;&quot;&quot;
          master=self._master
          rows=self._rows
          cols=self._cols
          width=self._width
          height=self._height
  
          super().__init__(master, rows, cols, width, height, **kwargs)  
          
      def get_bbox(self, position):
          &quot;&quot;&quot;
          Returns the bounding box for the (row, column) position;
          this is a tuple containing information about the pixel positions of the edges of the shape,
          in the form (x min, y min, x max, y max).
  
          &quot;&quot;&quot;
  </code></pre>
  <p>I am not sure how to write this get_bbox function.Would you please help me by giving a way?</p>
  <p>Thanks</p>