首先,我从一个表中选择所有记录并将它们列在我的GUI中。 在下一个记录的每一个屏幕上都有两个更新记录的按钮。我尝试了几种不同的方法,但似乎无法从要查看/更新的特定记录中获取信息。我试过在按钮上添加文本变量等
我的问题是,如何查看和/或更新我表中所有行的列表中的特定行?在
def Show_Keylog_Records(self):
data = self.Select_Keylog_Records()
for index, dat in enumerate(data):
Row_ID = index
Key_Num = dat[0]
self.Row_ID = Frame(self.Result_Frame, bg='#333')
Label(self.Row_ID, text=dat[0]).pack(side=LEFT, expand=YES, fill=X)
Label(self.Row_ID, text=dat[1]).pack(side=LEFT, expand=YES, fill=X)
Label(self.Row_ID, text=dat[2]).pack(side=LEFT, expand=YES, fill=X)
Label(self.Row_ID, text=dat[3]).pack(side=LEFT, expand=YES, fill=X)
Button(self.Row_ID, text='view', textvariable=Row_ID, command=self.View_Keylog_Record).pack(side=RIGHT)
Button(self.Row_ID, text='Delete', command=self.Delete_Keylog_Record).pack(side=RIGHT, padx=5)
self.Row_ID.pack(side=TOP, fill=X, pady=3)
def Select_Keylog_Records(self):
c.execute("SELECT * FROM KeyLog")
return c.fetchall()
def View_Keylog_Record(self):
Record = (Row_ID.get(),)
c.execute('SELECT * FROM KeyLog WHERE index=?', Record)
print c.fetchone()
我认为您需要的是将
index
传递给函数。如果是这样,请按如下方式更改按钮实例化:或
^{pr2}$注意您必须
import functools
才能使用第二个选项。在对“删除”按钮进行类似更改,然后按如下方式修改函数:
进行相应的更改以删除\u Keylog_记录,并查看这是否适合您。在
相关问题 更多 >
编程相关推荐