title: Spreadsheet GUI - Python 3.4
body: <p>I would like the user to copy data from Excel and paste it in the spreadsheet like GUI and then press OK. This data (three columns +100/1000 rows) will be stored in an array for subsequent calculations further on in the program. </p>
  
  <p>I would prefer to use tkinter since it's already included in my Python installation and others like wxPython are not supported by Python 3.4.  </p>
  
  <p>I already have the following but there are some issues:
  1. I cannot paste data into the table.
  2. The number of rows is fixed. So what to do if my data is bigger than the table?</p>
  
  <p>
  
  <pre><code>class SimpleTableInput(tk.Frame):
  def __init__(self, parent, rows, columns):
      tk.Frame.__init__(self, parent)
  
      self._entry = {}
      self.rows = rows
      self.columns = columns
  
  
      # create the table of widgets
      for row in range(self.rows):
          for column in range(self.columns):
              index = (row, column)
              e = tk.Entry(self)
              e.grid(row=row, column=column, stick="nsew")
              self._entry[index] = e
      # adjust column weights so they all expand equally
      for column in range(self.columns):
          self.grid_columnconfigure(column, weight=1)
      # designate a final, empty row to fill up any extra space
      self.grid_rowconfigure(rows, weight=1)
  
  def get(self):
      '''Return a list of lists, containing the data in the table'''
      result = []
      for row in range(self.rows):
          current_row = []
          for column in range(self.columns):
              index = (row, column)
              current_row.append(self._entry[index].get())
          result.append(current_row)
      return result
  
  class Example(tk.Frame):
  def __init__(self, parent):
      tk.Frame.__init__(self, parent)
      self.table = SimpleTableInput(self, 20, 3)
      self.table.pack(side="top", fill="both", expand=True)
  
  
  root = tk.Tk()
  Example(root).pack(side="top", fill="both", expand=True)
  root.mainloop()&gt;
  </code></pre>