1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
"""
Installer Playsound :
pip3.10 install playsound
https://pypi.org/project/playsound/
Aide TKinter : https://www.youtube.com/watch?v=N4M4W7JPOL4&
Installer pyinstaller :
pip3.10 install pyinstaller
Installer UPX pour obtenir une appli plus légère
sudo apt-get update -y
sudo apt-get install -y upx
"""
from tkinter import *
from playsound import playsound
back_color = "#C4AFAC"
# Création de la fonction qui va jouer
def jouer_mp3():
playsound('texte-fr.mp3')
playsound('texto-es.mp3')
# Créer une fenêtre
window = Tk()
# Personnaliser la fenêtre
window.title("Lire un mp3")
window.geometry("480x240")
window.minsize(240, 180)
# window.iconbitmap("Logo.ico") # Impossible à faire fonctionner...
window.config(background=back_color)
# Création d'un cadre
frame = Frame(window, bg=back_color) # , bd= 1, relief=SUNKEN
# Ajout de Widgets
label_title1 = Label(frame, text="Cliquez pour écouter", font=("arial", 25), bg=back_color, fg="white")
label_title1.pack()
label_title2 = Label(frame, text="Programme de test", font=("courier", 15), bg=back_color, fg="white")
label_title2.pack()
# Ajout d'un bouton
mp3_button = Button(frame,
text="Jouer le mp3",
font=("Times new roman", 20),
bg="white",
fg="black",
command=jouer_mp3
)
mp3_button.pack(pady=25)
# Affichage du cadre
frame.pack(expand=YES)
# Afficher la fenêtre
window.mainloop() |
Partager