如何使用tkinter-python在一个按钮中拥有不同的功能



我正在尝试用不同的sql函数制作一个研究按钮。问题是该按钮只能使用一个sql函数,不能再使用了。这是我的按钮代码:

research_button = Button(app, text="Rechercher", command=lambda:[self.surface_result(), self.eppaisseur_moy_result()])
research_button.grid(row=4, column=0, padx=10, pady=10)

这是我的函数代码:

def surface_result(self):
cursor.execute("SELECT helicopter_surface_mouille FROM Helicopter")
row = cursor.fetchone()
for x in row:
surface_result_label = Label(app, text=x, background = 'white')
surface_result_label.grid(row=5, column=1, sticky=W)
def eppaisseur_moy_result(self):
cursor.execute("SELECT produitp_epaisseur_moy FROM ProduitP")
row2 = cursor.fetchone()
for x in row2 :
epaisseur_seche_moy_result_label = Label(app, text=x, background = 'white')
epaisseur_seche_moy_result_label.grid(row=6, column=1, sticky=W)

第一个函数正在工作,但第二个函数不工作,我有一个错误:mysql.connecter.errors.InternalError:找到未读结果

好的,我刚刚找到了解决方案:

cursor = mydb.cursor(buffered = True)

这将在没有任何错误的情况下执行所有操作:(

相关内容

最新更新