[Python] Changing buttons on a frame after language change

Discussão em 'Python' iniciado por Stack, Dezembro 31, 2024.

  1. Stack

    Stack Membro Participativo

    I am trying to create a small game that allows the user to guess words. At this moment it is single language (Dutch) but I also want to allow French words so I've placed a listbox on the form that allows language selection. For Dutch I only need 26 buttons (one for each letter) but for French I need 6 extra for the accented letters (all stored in a multidimensional array). When the other language is selected I run a function that should remove all buttons and put the new version of the buttons on the frame.

    I thought I could do this with this code:

    try:
    Btns = ButtonFrame.grid_slaves()
    for l in Btns:
    l.destroy()
    # print("Deleting buttons")
    except:
    print("Error")


    but this doesn't work, I always get a index out of range error for the letter array. How can I dynamically change my buttons (add or subtract buttons from the frame)?

    Continue reading...

Compartilhe esta Página