【问题标题】:Tkinter: Paste Excel Cells into Different Entry WidgetsTkinter:将 Excel 单元格粘贴到不同的条目小部件中
【发布时间】:2015-06-23 01:36:38
【问题描述】:

我使用 Tkinter (python 2.7.10) 创建了一个条目小部件网格。我想要这样,如果我从 excel 文件中复制和粘贴不同的单元格,这些单元格也会粘贴到小部件中的单独单元格中。这是实际创建小部件的一小段代码。

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()

现在,当我粘贴时,所有不同的 excel 条目都粘贴到一个条目小部件单元格中。

【问题讨论】:

    标签: python excel python-2.7 tkinter


    【解决方案1】:

    您需要自己显式处理<<Paste>> 事件,解析数据,然后将其插入到各个条目小部件中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-20
      • 1970-01-01
      • 2017-10-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多