【发布时间】:2017-03-22 22:25:01
【问题描述】:
首先,我从表中选择所有记录并在我的 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()
【问题讨论】:
-
您是在询问如何与
View_Keylog_Record通信您对哪个数据库行感兴趣? -
我要问的问题是:如何将我想要从 Show_Keylog_Records 更改为 View_Keylog_Record 的任何行的索引(或任何其他数据)传递给 View_Keylog_Record