title: Pulling excel rows to display as a grid in tkinter
body: <p>I am imaging fluorescent cells from a 384-well plate and my software spits out a formatted excel analysis of the data (16 rowsx24 columns of images turns into a list of data, with 2 measurements from each well, ~800 data points). Because there is a lot of manual interaction with the data, I want to automate my work by taking the information that's indexed in the excel sheet and map it as a tkinter grid. I want to take my data, have it formatted from a list back to the original 16x24 display. I want to be able to interact with that data, among other things, but as a newbie in python, I'm having a difficult time mapping this data. </p>
  
  <p>I  used pandas to read my dataframe, but can't seem to display my list to the appropriate grid box. Ideally, I'd like the values in the excel list to display on the corresponding cell in the tkinter grid. For example, in my excel list, [1]:<a href="https://imgur.com/a/N8HAtYl" rel="nofollow noreferrer">https://imgur.com/a/N8HAtYl</a>, the two data points from each well are listed. I want to take the values from each cell and display them to the corresponding grid in tkinter, so the average of values of "A1" would be mapped onto column 1, row 1 of the grid, A2 would be col 2 row 1, A3 would be col 3 row 1, and so on and so forth. </p>
  
  <p>Any help would be great, thank you. </p>
  
  <pre><code>from tkinter import *
  
  import pandas as pd
  
  from pandas import ExcelWriter
  
  from pandas import ExcelFile
  df = pd.read_excel('/Users/Zammam/PycharmProjects/Filipin_Analysis_Zammam/data.xlsx', sheet_name='Dataps')
  print(()
  class Cell():
      FILLED_COLOR_BG = "green"
      EMPTY_COLOR_BG = "white"
      FILLED_COLOR_BORDER = "green"
      EMPTY_COLOR_BORDER = "black"
  
      def __init__(self, master, x, y, size):
          self.master = master
          self.abs = x
          self.ord = y
          self.size= size
          self.fill= False
  
      def _switch(self):
          """ Switch if the cell is filled or not. """
          self.fill= not self.fill
  
      def draw(self):
  
          if self.master != None :
              fill = Cell.FILLED_COLOR_BG
              outline = Cell.FILLED_COLOR_BORDER
  
              if not self.fill:
                  fill = Cell.EMPTY_COLOR_BG
                  outline = Cell.EMPTY_COLOR_BORDER
  
              xmin = self.abs * self.size
              xmax = xmin + self.size
              ymin = self.ord * self.size
              ymax = ymin + self.size
  
              self.master.create_rectangle(xmin, ymin, xmax, ymax, fill = fill, outline = outline)
  
  class CellGrid(Canvas):
      def __init__(self,master, rowNumber, columnNumber, cellSize, *args, **kwargs):
          Canvas.__init__(self, master, width = cellSize * columnNumber , height = cellSize * rowNumber, *args, **kwargs)
  
          self.cellSize = cellSize
  
          self.grid = []
          for row in range(rowNumber):
  
              line = []
              for column in range(columnNumber):
                  line.append(Cell(self, column, row, cellSize))
  
              self.grid.append(line)
  
          #memorize the cells that have been modified to avoid many switching of state during mouse motion.
          self.switched = []
  
          #bind click action
          self.bind("&lt;Button-1&gt;", self.handleMouseClick)  
          #bind moving while clicking
          self.bind("&lt;B1-Motion&gt;", self.handleMouseMotion)
          #bind release button action - clear the memory of midified cells.
          self.bind("&lt;ButtonRelease-1&gt;", lambda event: self.switched.clear())
  
          self.draw()
  
  
  
      def draw(self):
          for row in self.grid:
              for cell in row:
                  cell.draw()
  
      def create_text(self):
          for row in self.grid:
              for cell in row:
                  for i in df:
                      cell.create_text(text = df)
  
  
  
      def _eventCoords(self, event):
          row = int(event.y / self.cellSize)
          column = int(event.x / self.cellSize)
          return row, column
  
      def handleMouseClick(self, event):
          row, column = self._eventCoords(event)
          cell = self.grid[row][column]
          cell._switch()
          cell.draw()
          #add the cell to the list of cell switched during the click
          self.switched.append(cell)
  
      def handleMouseMotion(self, event):
          row, column = self._eventCoords(event)
          cell = self.grid[row][column]
  
          if cell not in self.switched:
              cell._switch()
              cell.draw()
              self.switched.append(cell)
  
  
  if __name__ == "__main__" :
      app = Tk()
  
      grid = CellGrid(app, 16, 24, 15)
      grid.pack()
  
      app.mainloop()
  </code></pre>