tkinter
我曾经使该代码块适用于表,但是我想用输入替换它们,只是得到一个错误,提示import pandas as pd
import tkinter as tk
a =[]
tempList2=[{'Date': '21-Aug-2019', 'Day': 'Sunday', 'Status': 'This is the message. It should be wrapped!!'}, {'Date': '22-Aug-2019', 'Day': 'Monday', 'Status': 'Message Delivered'}, {'Date': '23-Aug-2019', 'Day': 'Tuesday', 'Status': 'Invalid Data found!! Please retry'}]
for i in tempList2:
print(i)
print(type(i))
b = list(i.values())
a.append(b)
print(a)
tempList = a
df = pd.DataFrame(tempList)
# --- functions ---
def change(event, row, col):
# get value from Entry
value = event.widget.get()
# set value in dataframe
df.iloc[row,col] = value
print(df)
# --- main --
root = tk.Tk()
# create entry for every element in dataframe
rows, cols = df.shape
for r in range(rows):
for c in range(cols):
e = tk.Entry(root)
e.insert(0, df.iloc[r,c])
e.grid(row=r, column=c)
# ENTER
e.bind('<Return>', lambda event, y=r, x=c: change(event,y,x))
# ENTER on keypad
e.bind('<KP_Enter>', lambda event, y=r, x=c: change(event,y,x))
# start program
root.mainloop()
。这是什么意思?我该如何解决?
谢谢。