posted 2 years ago
Hi all brothers and sisters my question is how i can make many buttons for all records from database in tkinter that each button delete one record that in loop we made i write this code but with this way delete last record with all button how is posible each button delete that record in that round made together with button in loop?
Thank You Very Much God Blesed You And Your Love And Your Familly :X.
def deletebtn():
connection = sqlite3.connect('DBphonebook.db')
c = connection.cursor()
c.execute("DELETE from phonebook WHERE Name= :Name AND Familly= :Familly", {'Name':i[0], 'Familly':i[1]})
connection.commit()
connection.close()
for i in listofrecords:
x += 20
Button(second_frame, text='delete', command=deletebtn).grid(row=x , column=0, padx=1, pady=1)
Label(second_frame, text= i[3]).grid(row=x, column=150, pady=10, padx=130)
Label(second_frame, text= i[2]).grid(row=x, column=200, pady=10, padx=30)
Label(second_frame, text= i[0]).grid(row=x, column=300, pady=10, padx=30)
Label(second_frame, text= i[1]).grid(row=x, column=250, pady=10, padx=30)
In This Code We Have Many Code Before For Making Window And Database Records But In This Loop We Put Every Record From Database With Label And Before This Every Round We Make One Button For Delete Each Record But Why In Every Round Every Button Don't Work For Delete That Record In That round Beacuase In One Funtion That Name Is deletebtn I Put Deleting Proccess For Database Commands? How This Is Possible ?
Power Of Inteligence Is Power Of God.