Jun-08-2021, 07:50 PM
(This post was last modified: Jun-08-2021, 08:20 PM by Yoriz.
Edit Reason: Translated the title to English
)
Hi,
I made a simple left-justified menu with buttons. Assign functions as commands to buttons. That is, the menu contents are within the functions.
Now there is a problem.
I am pulling the data in this list via MongoDB. The items in this list are the data in the MongoDB collection.
When I click on the "Sınıf Yönetimi" button from the left-justified menu with the buttons, the sinifYonetimi function works.
But as I run the SinifYonetimi function through the menu, it constantly re-inserts the items in MongoDB.
As you can see in the picture above, the data has been inserted 3 times. This is because I pressed the "Sınıf Yönetimi" button from the left menu 3 times. Upon pressing it, the sinifYonetimi function ran 3 times and inserted 3 times.
It's a bug and I haven't been able to fix it. How can I solve this problem?
Code:
I made a simple left-justified menu with buttons. Assign functions as commands to buttons. That is, the menu contents are within the functions.
Now there is a problem.
I am pulling the data in this list via MongoDB. The items in this list are the data in the MongoDB collection.
When I click on the "Sınıf Yönetimi" button from the left-justified menu with the buttons, the sinifYonetimi function works.
But as I run the SinifYonetimi function through the menu, it constantly re-inserts the items in MongoDB.
As you can see in the picture above, the data has been inserted 3 times. This is because I pressed the "Sınıf Yönetimi" button from the left menu 3 times. Upon pressing it, the sinifYonetimi function ran 3 times and inserted 3 times.
It's a bug and I haven't been able to fix it. How can I solve this problem?
Code:
def sinifYonetimi(): sinifyonetimiaciklama = Label(fg="white", bg="#202020") veriyicek = siniflar.find().sort("sinif") i = 1 for x in veriyicek: print(x["sinif"]) liste.insert(i, x["sinif"]) i = i + 1 liste.configure(width=50) sinifeklebuton.grid(column=3, row=5, sticky=E)# Buton liste.grid(column=2, columnspan=3) sinifadiyazma.grid(column=3, row=5, sticky=NW)# Entry sinifadiyazma.configure(width=30) silbuton.grid(column=2, columnspan=3) silbuton.configure(width=10, height=1) islemsec.grid_remove() menubuton2 = Button(text="Sınıf Yönetimi", fg="white", bg="#282528", height=4, command=sinifYonetimi)How can I solve the problem? I don't want it to be re-inserted all the time. It is constantly re-inserting as I press the button from the menu. How can I prevent it from re-inserting? Thanks in advance.