domingo, 25 de noviembre de 2018

Ocultar/mostrar imagen P9



 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
#Aportacion.- Alan Hernandez Mijangos
#Programa.- que toma un archivo GIF y lo muestra al hacer clic en un boton
# -*- coding: utf-8 -*-import Tkinter as tk
from Tkinter import *

ventana = Tk()
ventana.geometry('400x400')
ventana.config(bg="black")
ventana.title("Mostrando y ocultando un boton con una imagen")

def btn_hide():
    if b1.winfo_ismapped():
        b1.place_forget()
        b2.configure(text="Mostrar", width=30)
    else:
        b1.place(x=100, y=100)
        b2.configure(text="Ocultar", width=30)

imgBoton = PhotoImage(file="icon.gif")
b1 = Button(ventana, text="Boton 1", image=imgBoton, fg="black", width=200)
b1.place(x=90, y=50)
b2 = Button(ventana, text="Ocultar ", command=btn_hide, fg="black", width=15)
b2.place(x=130, y=280)

ventana.mainloop()

No hay comentarios.:

Publicar un comentario