Python Forum
[Tkinter] listbox constantly being added to the list.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] listbox constantly being added to the list.
#1
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:

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.
Reply


Messages In This Thread
listbox constantly being added to the list. - by speedev - Jun-08-2021, 07:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  PysimpleGUI - listbox with list jamesaarr 2 4,391 Sep-06-2021, 09:52 AM
Last Post: jamesaarr
  [Tkinter] list box select event triggers when selecting another listbox Roshan 1 4,570 May-09-2021, 08:27 AM
Last Post: Yoriz
  How to format a list when displaying in a tkinter Listbox nortski 3 9,724 Apr-03-2018, 02:31 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020