def draw(self):
        if self._root is None: return
        LEFT_MARGIN = BOT_MARGIN = 15
        TOP_MARGIN = 5
        c = self._canvas
        c.delete('all')
        N = self._chart.num_leaves()+1
        dx = (int(c['width'])-LEFT_MARGIN)/N
        dy = (int(c['height'])-TOP_MARGIN-BOT_MARGIN)/N

        c.delete('all')

        # Labels and dotted lines
        for i in range(N):
            c.create_text(LEFT_MARGIN-2, i*dy+dy/2+TOP_MARGIN,
                          text=repr(i), anchor='e')
            c.create_text(i*dx+dx/2+LEFT_MARGIN, N*dy+TOP_MARGIN+1,
                          text=repr(i), anchor='n')
            c.create_line(LEFT_MARGIN, dy*(i+1)+TOP_MARGIN,
                          dx*N+LEFT_MARGIN, dy*(i+1)+TOP_MARGIN, dash='.')
            c.create_line(dx*i+LEFT_MARGIN, TOP_MARGIN,
                          dx*i+LEFT_MARGIN, dy*N+TOP_MARGIN, dash='.')

        # A box around the whole thing
        c.create_rectangle(LEFT_MARGIN, TOP_MARGIN,
                           LEFT_MARGIN+dx*N, dy*N+TOP_MARGIN,
                           width=2)

        # Cells
        self._cells = [[None for i in range(N)] for j in range(N)]
        for i in range(N):
            for j in range(i, N):
                t = c.create_rectangle(j*dx+LEFT_MARGIN, i*dy+TOP_MARGIN,
                                       (j+1)*dx+LEFT_MARGIN,
                                       (i+1)*dy+TOP_MARGIN,
                                       fill='gray20')
                self._cells[i][j] = t
                def cb(event, self=self, i=i, j=j): self._click_cell(i,j)
                c.tag_bind(t, '<Button-1>', cb)

        # Inactive box
        xmax, ymax = int(c['width']), int(c['height'])
        t = c.create_rectangle(-100, -100, xmax+100, ymax+100,
                               fill='gray50', state='hidden',
                               tag='inactivebox')
        c.tag_lower(t)

        # Update the cells.
        self.update()
dataset/ETHPy150Open nltk/nltk/nltk/app/chartparser_app.py/ChartMatrixView.draw/original