Reputation: 820
I've created a grid of entry widgets using Tkinter (python 2.7.10). I'd like to have so that if I copy and pasted different cells from an excel file, the cells would paste into separate cells in the widget as well. This is a small snippet of the code that actually creates the widgets.
root = Tk()
#create an array of height entries
height = 5
width = 5
for i in range(1,height+1): #Rows
for j in range(width): #Columns
b = Entry(root, text="")
b.grid(row=i, column=j)
#initialize column headers
Label(root, text="Plan ID").grid(row=0, column=0, sticky=W)
Label(root, text="WACOG").grid(row=0, column=1, sticky=W)
Label(root, text="Margin").grid(row=0, column=2, sticky=W)
Label(root, text="Start Date").grid(row=0, column=3, sticky=W)
Label(root, text="State").grid(row=0, column=4, sticky=W)
excelise = Button(root, text="Excelise!", command=writeToExcel).grid(row=height+1, column=4)
xmlise = Button(root, text="XMLise!", command=writeToXML).grid(row=height+1, column=3)
mainloop()
Right now, when I paste, all of the different excel entries is pasted into one entry widget cell.
Upvotes: 0
Views: 1591
Reputation: 385980
You will need to explicitly handle the <<Paste>>
event yourself, parse the data, and then insert it into the individual entry widgets.
Upvotes: 1