- - coding: utf-8 - -s
LIBRARIES
from tkinter import Tk, Frame, Label, Button from PIL import ImageTk, Image
EVENT EXIT APP WITH KEY -ESC -
def close (event): root.withdraw () # if you want to bring it back sys.exit () # if you want to exit the entire thing
********************************************* ******** Main Script *********************************** ****************
if name == " main ":
INITIAL STATUS
AnchoFrame = 600 #parametro de ancho del frame
AltoFrame = 400
GRAPHICAL INTERFACE
root = Tk()
ox = root.winfo_screenwidth()/2
oy = root.winfo_screenheight()/2[introducir la descripción de la imagen [![introducir la descripción de la imagen aquí][1]][1]aquí][1]
root.geometry("=%dx%d+%d+[![introducir la descripción de la imagen aquí][1]][1]%d" % (AnchoFrame, AltoFrame, (ox - (AnchoFrame/2)), (oy-(AltoFrame/2))) )
root.overrideredirect(1) #sacarle los bordes a la ventana #sin bordes
root.resizable(False,False) #no puede cambiar de tamaño
#root.wm_attributes('-alpha', 0.99) #Transparencia
root.config(bd=0) #grosot borde
root.config(relief="flat", bg="black", borderwidth = 0) #stilo borde
miFrame=Frame(root, width=AnchoFrame, height=AltoFrame) #tamaño del frame
miFrame.config(relief="flat", bg="grey38") #stilo de frame
ruta_img = Image.open("fondo.png")
ruta_img = ruta_img.resize((AnchoFrame,AltoFrame),Image.ANTIALIAS)
image = ImageTk.PhotoImage(ruta_img)
background = Label(image=image) #Fondo
background.pack()
miFrame.pack() #empaquetado del frame
ruta_img_boton = Image.open("boton.png")
#ruta_img_boton = ruta_img_boton.resize((500,100),Image.ANTIALIAS)
image2 = ImageTk.PhotoImage(ruta_img_boton)
BOTON = Button(image=image2,command=lambda:root.destroy(), relief="flat")
BOTON.place(x=140,y=280)
ESC EVENT
root.bind('<Escape>', close) #EVENTO DE LA TECLA ESC
MAINLOOP
root.mainloop()