In this code, I'm importing a dictionnary (dict_nombre) from another Python file(dictnombre.py).
The imported dictionnary is passed in the variable "dict".
Later the code is deleting the key and values of "dict". Until here, everything is working as expected.
But when I click after that on the button "bouton_chiffre", "dict" remains empty although the function should pass again the imported dictionnary to "dict"
dict_nombre in the file dictnombre.py:
dict_nombre={'un (chiffre)':'yi-',
'deux':'èr',
'trois':'sa-n',
'quatre':'sì',
'cinq':'wû',
'six':'liù',
'sept':'qî',
'huit':'ba-',
'neuf (chiffre)':'jiû',
'dix':'shí'
}
The code:
...
import dictnombre
...
def nombres():
global dict
dict=dictnombre.dict_nombre
...
del dict[key_aleatoire]
...
bouton_chiffre=Button(cadre_bouton,text="Nombres seulement",width=15,height=1,bg="blue",bd=5, command=nombres)
bouton_chiffre.pack(side=LEFT)
SOLUTION (29.03.2023):
dict_copy=dictnombre.dict_nombre.copy()
Thanks everyone for the help !