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
| import os.path
from os import chdir # Pour chargement des images dans autre répertoire chdir = chg de répertoire
from tkinter import *
# Instancification
fenMsgBox = Toplevel()#Tk()
#
# def hh():
# del PHOTO4
# fenMsgBox.destroy ()
def foncFenAlerte1Choix(titre, msg):
"""MsgBox d'alerte, un seul choix : fermeture"""
# Constantes
NOMDOS = os.getcwd() # Nom du dossier courant
chdir(NOMDOS + '\Images') # Chg de répertoire courant pour charger les images
PHOTO4 = PhotoImage(master=fenMsgBox, file='Icone30x30_Exit.png')
chdir(NOMDOS) # Chg de répertoire courant pour revenir a la normale
# Création fenêtre
fenMsgBox.title(titre)
fenMsgBox.configure(bg="Slate Gray")
fenMsgBox.geometry('300x360')
# Objets
objMsgBox1 = Label(fenMsgBox, height=20, width=40, text=msg, bg="Gray")
bouValidMsgBox = Button(fenMsgBox, image=PHOTO4, bg="Slate Gray", command=fenMsgBox.destroy)
# bouValidMsgBox = Button (fenMsgBox, image=PHOTO4, bg="Slate Gray", command=hh())
# positionnements des objets
objMsgBox1.pack(side=TOP)
bouValidMsgBox.pack(side=BOTTOM)
# Centrage fenêtre
from Fonctions.FoncCentreEcran import centreFenetre
centreFenetre (fenMsgBox)
# Fenêtre fenMsgBox en 1er plan
fenMsgBox.focus_set()
# Réception d'événements pour fenMsgBox
fenMsgBox.mainloop() |