2
我想创建一个gui控件,它将通过.sql文件进行搜索。我正在使用tkinter,并且我有一个for循环,它不工作。它只会显示一个结果时,有许多5.如何获得for循环与python 2.7中的tkinter一起使用?
def OnPressEnter(self,event):
with con:
cur = con.cursor()
t = self.entryVariable.get()
cur.execute("select * from Dict where Def LIKE ? OR word LIKE ? LIMIT 12", ('%'+t+'%', '%'+t+'%'))
rows = cur.fetchall()
for row in rows:
#printing second & third column(See tuples)
self.labelVariable.set(row[1])
self.labelVariable.set(row[2])
如果我输入“苹果”我只会让我的结果之一即是“499 $”。那么如何让循环工作?
我仍然只有一个结果,当有5个。看起来好像有什么与循环。 [这是我的gui](http://imgur.com/AALHCzk)&我的[console正在输出这个](http://imgur.com/gaWtQPw)。 – Bossman759 2013-03-03 02:34:43
你可以查看完整的代码[这里](https://github.com/bossman759/wiki-serach/blob/master/gui.py),如果有帮助。 – Bossman759 2013-03-03 02:50:47
将'label =“”'移出for循环[here](https://github.com/bossman759/wiki-serach/blob/master/gui.py#L78)和其他任何地方。每次迭代都会重置'label'的值,抛弃最后一行值。 – Raufio 2013-03-03 03:05:10