I have tried several options posted online but none seem to work. I even tried assigning a separate variable to it and then using the delete command but even that doesn't work. Student_table has been defined in the class.
self.Student_table.delete(*self.Student_table.get_children())
- this is precisely where I'm getting an error
AttributeError: 'Student' object has no attribute 'Student_table'
this is the code
def search_data(self):
mycon=mysql.connector.connect(host="localhost",user="X",passwd="X",database="test")
cur=mycon.cursor()
cur.execute("select * from student where '{}' = '{}'".format(self.search_by.get(),self.search_txt.get()))
rows=cur.fetchall()
self.Student_table.delete(*self.Student_table.get_children())
for row in rows:
self.Student_table.insert('',END,values=row)
mycon.commit()
mycon.close()
question from:
https://stackoverflow.com/questions/66058726/getting-an-attribute-error-even-though-i-have-defined-it-in-a-class-using-self 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…