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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
"""
Speed Booking
Installer Playsound :
pip install playsound
https://pypi.org/project/playsound/
Bases de TKinter : https://www.youtube.com/watch?v=N4M4W7JPOL4&
Pour la compilation
Installer UPX pour obtenir une appli plus légère
sudo apt-get update -y
sudo apt-get install -y upx
Informations pour intégrer les médias :
https://medium.com/swlh/easy-steps-to-create-an-executable-in-python-using-pyinstaller-cc48393bcc64
https://www.askpython.com/python/pyinstaller-executable-files
"""
from tkinter import *
from playsound import playsound
# Bibliothèques nécessaires pour l'utilisation du chemin relatif du fichier mp3
import os
import sys
# Création de la fonction pour rendre locale la recherche du fichier son (Nécessaire lors de l'execution du paquet)
def resourcePath(relativePath):
if hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS, relativePath)
return os.path.join(os.path.abspath("."), relativePath)
# Variable pour modifier la couleur d'arrière plan de tous les Widgets
back_color = "#C4AFAC"
# Création de la fonction qui va jouer le son
def jouer_mp3():
# playsound('texto-es.mp3')
playsound(resourcePath('texto-es.mp3')) # Indication du chemin relatif du fichier mp3
# Création de la fenêtre principale
window = Tk()
# Personnalisation 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 des Widgets contenant les textes
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 contenant les textes et le bouton
frame.pack(expand=YES)
# Affichage de la fenêtre principale
window.mainloop() |
Partager