I would like to to use tkinter and checkboxs to make a selection of files in a directory and save those files names in a list when I press a button :
import speech_recognition as sr
import playsound
import os
import glob
import unidecode
import pickle
import random
import tkinter
from tkinter.constants import *
ldv=os.listdir("D:/FFOutput/")
i=0
ldv1=[]
while i<len(ldv):
ldv1.append(unidecode.unidecode(ldv[i]))
i=i+1
print(ldv1)
tk = tkinter.Tk()
frame = tkinter.Frame(tk, relief=RIDGE, borderwidth=10)
frame.pack(fill=BOTH,expand=1)
label = tkinter.Label(frame, text="choose file(s)")
label.pack(fill=X, expand=1)
a=0
while a<len(ldv1):
bouton=tkinter.Checkbutton(tk, text=ldv1[a], command=print(ldv1[a]))
a=a+1
bouton.pack()
button = tkinter.Button(frame,text="Exit",command=tk.destroy)
button.pack(side=BOTTOM)
lr=[]
buttonregister = tkinter.Button(tk,text="Register checked files names in list lr and close tk")
buttonregister.pack(side=BOTTOM)
print(lr)
tk.mainloop()
When i click on buttonregister i would like to append files names in the list lr and close the frame.
Exemple : enter image description here In that exemple, I wish to print(lr) "['alors soyez pret.mp3','c'est bien.mp3'] in the shell when i click on the button.
Thank you
Aucun commentaire:
Enregistrer un commentaire