Ver canvas y poligonos
Mostrando entradas con la etiqueta graficacion. Mostrar todas las entradas
Mostrando entradas con la etiqueta graficacion. Mostrar todas las entradas
miércoles, 11 de marzo de 2020
lunes, 10 de febrero de 2020
martes, 28 de enero de 2020
miércoles, 9 de octubre de 2019
jueves, 19 de septiembre de 2019
Metodos de Orden en Array de Python
https://uniwebsidad.com/libros/python/capitulo-7/metodos-de-orden
martes, 10 de septiembre de 2019
martes, 20 de agosto de 2019
Instalacion de el IDE pycharm para python:
Guia Aqui:
Otro IDE Recomendado aportacion: Victor Hugo Vazquez Gomez
https://code.visualstudio.com/
Sulime text
Otro IDE Recomendado aportacion: Victor Hugo Vazquez Gomez
https://code.visualstudio.com/
Sulime text
martes, 14 de mayo de 2019
Loteria de Ambro !!
import os #libreria para obtener rutas de direcciones en carpetas
import random # para generar numeros aleatorios
import threading #libreria para manejar hilos
from Tkinter import * # GUI,botones,label,menu,entry,tk,frame etc
import PIL
from PIL import Image, ImageTk # tratar imagenes ,png
import time # para tiermpos o dormir o espera o wait en segundos
import pygame # para juegos 2D y 3d
"""Variables globales"""
imagen = 0
stop = 0
dir = os.path.dirname(__file__)
Ccartas = dir + "/Cartas/" # establece la ruta hacia las imagenes de cartas
Csonido = dir + "/Sonidos/" # establece la ruta hacia los sonidos
play = 1
"""--------------------------------------------------------"""
def setimagen(nombre, x, y): # carga la imagen
global imagen # Declaro el uso de una variable global
img = Image.open(nombre) # cargo la imagen mandada como parametro
img.thumbnail((x, y), Image.ANTIALIAS) # establezco sus dimensiones y la propiedad antialiasado
imagen = ImageTk.PhotoImage(img) # la convierto a un formato soportado por los widgets de tkinter
return imagen # retorno el objeto con la imagen
def play():
global stop, play, TBoton # Declaro el uso de las variables stop y play
"""play: sirve para controlar la pulsasion del boton, si se pulsa una vez el boton jugar en pantalla deberia iniciar el juego
pero si se vuelve a pulsar deberia detenerse y dado que se usa el mismo boton para ambas acciones la uso para controlar las acciones
stop: se usa para controlar el hilo de ejecucion declarado, si stop vale 1 debera terminar el hilo, si vale 0 debera continuar hasta que se le indique"""
if play == 1:
TBoton.set("Pausar")
t = threading.Thread(target=hilo)
t.start()
stop = 0 # El hilo continua con normalidad
play = 0 # La proxima vez que se pulse el boton debera entrar en el else
else:
TBoton.set("Jugar")
play = 1 # La proxima vez que se pulse el boton debera entrar en el if
stop = 1 # Se detiene el hilo
def reproducirsonido(nombre):
pygame.mixer.music.load(nombre)
pygame.mixer.music.play()
def hilo():
global tiempo, cartas, Limagen, stop, Tetiqueta, spin
cartas = ["EL GALLO", "EL DIABLITO", "LA DAMA", "EL CATRIN", "EL PARAGUAS", "LA SIRENA", "LA ESCALERA",
"LA BOTELLA", "EL BARRIL", "EL ARBOL", "EL MELON",
"EL VALIENTE", "EL GORRITO", "LA MUERTE", "LA PERA", "LA BANDERA", "EL BANDOLON", "EL VIOLINCELLO",
"LA GARZA", "EL PAJARO", "LA MANO", "LA BOTA",
"LA LUNA", "EL COTORRO", "EL BORRACHO", "EL NEGRITO", "EL CORAZON", "LA SANDIA", "EL TAMBOR",
"EL CAMARON", "LAS JARAS", "EL MUSICO", "LA ARANA",
"EL SOLDADO", "LA ESTRELLA", "EL CAZO", "EL MUNDO", "EL APACHE", "EL NOPAL", "EL ALACRAN", "LA ROSA",
"LA CALAVERA", "LA CAMPANA", "EL CANTARITO",
"EL VENADO", "EL SOL", "LA CORONA", "LA CHALUPA", "EL PINO", "EL PESCADO", "LA PALMA", "LA MACETA",
"EL ARPA", "LA RANA"]
reproducirsonido(Csonido + "inicio.ogg")
time.sleep(3)
while True:
nombre = str(cartas.index(random.choice(cartas)) + 1)
carta = Ccartas + nombre + ".png"
Limagen.config(image=setimagen(carta, 400, 400))
Tetiqueta.set("Salio: " + cartas[int(nombre) - 1])
sonido = Csonido + "s_(" + nombre + ").ogg"
reproducirsonido(sonido)
time.sleep(float(spin.get()))
if stop == 1:
break
ventana = Tk() #creamos un objeto ventana Tk()
ventana.config(bg="gray")#con config y Bg es al fondo color
contenedor = Frame(ventana, width=700, height=700) # poner un frame arriba del marco o ventana TK
contenedor.pack()#para cargar ventana y frame
Etitulo = Label(contenedor, text="Loteria Mexicana", font=("Forte", 40, "bold")).place(x=120, y=20)
Etiempo = Label(contenedor, text="Tiempo entre cartas: ", font=("Forte", 12, "bold"))
Etiempo.place(x=130, y=100)
spin = Spinbox(contenedor, values=[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], font=("Arial", 12, "bold"))
spin.place(x=295, y=101)
Limagen = Label(contenedor)
Limagen.place(x=300, y=180)
TBoton = StringVar()
TBoton.set("Jugar")
Bplay = Button(contenedor, textvariable=TBoton, command=play)
Bplay.place(x=500, y=98)
Tetiqueta = StringVar()
Enombre = Label(contenedor, textvariable=Tetiqueta, font=("Arial", 40, "bold"))
Enombre.place(x=80, y=400)
pygame.init()
ventana.mainloop()
jueves, 9 de mayo de 2019
miércoles, 1 de mayo de 2019
jueves, 4 de abril de 2019
Paleta de Colores de Python
https://es.wikibooks.org/wiki/Python/Interfaz_gr%C3%A1fica_con_Tkinter/Los_nombres_de_los_colores
martes, 26 de marzo de 2019
Cuadros de Dialogo
#!/usr/bin/python
# -*- coding: utf-8 -*-
from Tkinter import *
from tkMessageBox import *
def pregunta():
askokcancel(title='Cancelar ok',message='¿Desea cancelar?')
def salir():
if askyesno('Verificar', '¿Pasas mas de 3 horas en el celular?'):
showwarning('Si', 'Haz otra actividad')
else:
showinfo('No', 'Muy bien')
def Libros():
if askyesno("Libros","¿Te gusta leer libros?"):
showinfo("Si","Muy bien")
else:
showerror("No", "Que mal")
def Peliculas():
askquestion(title="Pregunta",message="¿Te gustan las peliculas?")
def Cancelar():
askretrycancel(title="Cancelar/Reintentar",message="Reintentar o cancelar")
def Tresbotones():
askyesnocancel(title="Tres botones",message="Seleccione uno de tres botones")
Button(text='Salir', command=pregunta).pack(fill=X)
Button(text='Pregunta 1', command=salir).pack(fill=X)
Button(text='Pregunta 2', command=Libros).pack(fill=X)
Button(text='Pregunta extra', command=Peliculas).pack(fill=X)
Button(text='Cancelar/Reintentar', command=Cancelar).pack(fill=X)
Button(text='Tres botones', command=Tresbotones).pack(fill=X)
mainloop()
martes, 19 de marzo de 2019
Poligonos Gpo A 2018
from Tkinter import *
def funcion(seleccion, figura):
vs = Toplevel()
vs.configure(bg="gray")
vs.title(figura)
if seleccion == 1:
panel = Canvas(vs, width=1200, height=650, bg="gray")
panel.pack()
# cara
panel.create_polygon(415, 50, 235, 490, 365, 625, 755, 625, 850, 500, 700, 50,
width=1, fill="#e0af77", outline="brown")
# orejas
panel.create_polygon(415, 50, 60, 320, 175, 635, width=1, fill="#bb6400", outline="#000000")
panel.create_polygon(700, 50, 1045, 320, 896, 635, width=1, fill="#bb6400", outline="#000000")
# menton
panel.create_polygon(365, 625, 550, 415, 755, 625, width=1, fill="#bb6400", outline="#000000")
# ojos
panel.create_oval(420, 225, 480, 305, width=1, fill="#1a1200", outline="#000000")
panel.create_oval(630, 225, 690, 305, width=1, fill="#1a1200", outline="#000000")
# bigotes
panel.create_oval(475, 525, 490, 540, width=1, fill="#1a1200", outline="#000000")
panel.create_oval(615, 525, 630, 540, width=1, fill="#1a1200", outline="#000000")
panel.create_oval(445, 560, 460, 575, width=1, fill="#1a1200", outline="#000000")
panel.create_oval(610, 560, 625, 575, width=1, fill="#1a1200", outline="#000000")
panel.create_oval(480, 560, 495, 575, width=1, fill="#1a1200", outline="#000000")
panel.create_oval(640, 560, 655, 575, width=1, fill="#1a1200", outline="#000000")
# nariz
panel.create_oval(470, 305, 640, 500, width=1, fill="#1a1200", outline="#000000")
elif seleccion == 2:
panel = Canvas(vs, width=500, height=450, bg="gray")
panel.pack()
# cara
panel.create_polygon(200, 80, 120, 240, 120, 260, 140, 300, 160, 310, 240, 310, 310, 290, 350, 280, 360, 250,
350, 230,
340, 210, 250, 80,
width=1, fill="yellow", outline="black")
# cejas
panel.create_polygon(150, 190, 142, 200, 175, 225, 185, 210, width=1, fill="black", outline="black")
panel.create_polygon(200, 210, 210, 220, 248, 205, 240, 190, width=1, fill="black", outline="black")
# boca
panel.create_polygon(150, 250, 150, 260, 185, 255, 170, 263,
173, 275, 205, 263, 200, 240, width=2, fill="orange", outline="black")
# ojos
panel.create_oval(210, 215, 255, 235, width=1, fill="white", outline="black")
panel.create_oval(140, 218, 175, 235, width=1, fill="white", outline="black")
# pupilas
panel.create_oval(215, 215, 235, 235, width=1, fill="black", outline="black")
panel.create_oval(140, 218, 160, 235, width=1, fill="black", outline="black")
# cabello
panel.create_polygon(200, 80, 210, 75, 210, 60, 220, 50, 220, 70, 230, 50, 240, 50,
240, 60, 230, 70, 255, 65, 260, 70, 240, 78,
260, 80, 230, 88, width=1, fill="black", outline="black")
elif seleccion == 3:
panel = Canvas(vs, width=500, height=450, bg="skyblue")
panel.pack()
# cara
panel.create_oval(120, 80, 320, 200, width=2, fill="chocolate", outline="black")
# ojos
panel.create_oval(180, 100, 200, 130, width=1, fill="black", outline="black")
panel.create_oval(240, 100, 260, 130, width=1, fill="black", outline="black")
# pupila
panel.create_oval(185, 105, 190, 115, width=1, fill="white", outline="black")
panel.create_oval(245, 105, 250, 115, width=1, fill="white", outline="black")
# boca
panel.create_arc(170, 140, 270, 180, extent=180, style=CHORD, start=180, width=2, fill="black", outline="black")
# sonrisa rosybrown
panel.create_arc(155, 145, 190, 160, extent=100, style=ARC, start=180, width=2, fill="black", outline="black")
panel.create_arc(255, 145, 290, 160, extent=100, style=ARC, start=255, width=2, fill="black", outline="black")
panel.create_oval(195, 170, 245, 180, width=2, fill="pink2", outline="black")
# Petalos
panel.create_arc(200, 30, 240, 130, extent=180, start=0, style=CHORD, width=2, fill="yellow2", outline="black")
panel.create_arc(240, 40, 280, 130, extent=180, start=353, style=CHORD, width=2, fill="yellow2",
outline="black")
panel.create_arc(275, 58, 315, 145, extent=185, start=340, style=CHORD, width=2, fill="yellow2",
outline="black")
panel.create_arc(255, 100, 365, 140, extent=190, start=280, style=CHORD, width=2, fill="yellow2",
outline="black")
panel.create_arc(260, 130, 360, 170, extent=180, start=268, style=CHORD, width=2, fill="yellow2",
outline="black")
panel.create_arc(245, 200, 360, 165, extent=220, start=225, style=CHORD, width=2, fill="yellow2",
outline="black")
panel.create_arc(255, 163, 295, 233, extent=215, start=178, style=CHORD, width=2, fill="yellow2",
outline="black")
panel.create_arc(225, 155, 265, 245, extent=190, start=180, style=CHORD, width=2, fill="yellow2",
outline="black")
panel.create_arc(170, 155, 215, 245, extent=190, start=170, style=CHORD, width=2, fill="yellow2",
outline="black")
panel.create_arc(135, 158, 175, 233, extent=210, start=150, style=CHORD, width=2, fill="yellow2",
outline="black")
panel.create_arc(80, 155, 192, 195, extent=198, start=105, style=CHORD, width=2, fill="yellow2",
outline="black")
panel.create_arc(65, 120, 172, 160, extent=193, start=84, style=CHORD, width=2, fill="yellow2", outline="black")
panel.create_arc(128, 50, 168, 133, extent=200, start=10, style=CHORD, width=2, fill="yellow2", outline="black")
panel.create_arc(80, 83, 170, 123, extent=233, start=35, style=CHORD, width=2, fill="yellow2", outline="black")
panel.create_arc(160, 40, 200, 125, extent=190, start=2, style=CHORD, width=2, fill="yellow2", outline="black")
# tallo
panel.create_polygon(210, 200, 210, 250, 220, 290, 235, 330, 230, 380, 230, 410,
245, 410, 245, 380, 250, 330, 235, 290, 225, 250, 225, 200, width=1, fill="forestgreen",
outline="black")
# hoja derecha
panel.create_arc(230, 250, 310, 300, extent=270, start=0, style=CHORD, width=2, fill="forestgreen",
outline="darkgreen")
panel.create_arc(230, 265, 300, 295, extent=105, start=75, style=ARC, width=2, outline="darkgreen")
# hoja izquierda
panel.create_arc(125, 250, 215, 300, extent=270, start=270, style=CHORD, width=2, fill="forestgreen",
outline="darkgreen")
panel.create_arc(130, 265, 215, 295, extent=105, start=0, style=ARC, width=2, outline="darkgreen")
# fondo derecho
panel.create_arc(245, 300, 360, 410, extent=180, start=0, style=CHORD, width=1, fill="darkgreen",
outline="black")
panel.create_arc(245, 325, 380, 440, extent=170, start=0, style=CHORD, width=2, fill="forestgreen",
outline="darkgreen")
panel.create_arc(240, 340, 365, 460, extent=105, start=35, style=ARC, width=2, fill="forestgreen",
outline="darkgreen")
# fondo izquierdo
panel.create_arc(115, 310, 235, 400, extent=195, start=345, style=CHORD, width=1, fill="darkgreen",
outline="black")
panel.create_arc(105, 340, 235, 470, extent=170, start=20, style=CHORD, width=2, fill="forestgreen",
outline="darkgreen")
panel.create_arc(135, 350, 240, 490, extent=130, style=ARC, start=8, width=2, fill="black", outline="darkgreen")
# fondo medio
panel.create_arc(185, 345, 350, 500, extent=180, start=0, style=CHORD, width=2, fill="forestgreen",
outline="darkgreen")
panel.create_arc(185, 365, 315, 500, extent=130, style=ARC, start=40, width=2, outline="darkgreen")
elif seleccion == 4:
panel = Canvas(vs, width=600, height=800, bg="linen")
panel.pack()
# cara
panel.create_polygon(200, 300, 200, 450, 210, 470, 390, 470, 400, 450, 400, 300, width=2, fill="lemonchiffon",
outline="black")
# cabeza
panel.create_arc(100, 80, 500, 520, extent=180, start=0, style=CHORD, width=2, fill="gold", outline="black")
# manchas
panel.create_oval(290, 100, 380, 140, width=1, fill="goldenrod", outline="khaki") # 1
panel.create_oval(170, 110, 275, 190, width=1, fill="goldenrod", outline="khaki") # 2
panel.create_oval(130, 220, 180, 270, width=1, fill="goldenrod", outline="khaki") # 3
panel.create_oval(210, 200, 300, 290, width=1, fill="goldenrod", outline="khaki") # 4
panel.create_oval(320, 160, 350, 210, width=1, fill="goldenrod", outline="khaki") # 5
panel.create_oval(325, 235, 375, 275, width=1, fill="goldenrod", outline="khaki") # 6
panel.create_oval(390, 140, 465, 285, width=1, fill="goldenrod", outline="khaki") # 7
# ojos
panel.create_oval(240, 320, 270, 390, width=1, fill="black", outline="black")
panel.create_oval(330, 320, 360, 390, width=1, fill="black", outline="black")
# pupila
panel.create_oval(245, 325, 265, 355, width=1, fill="white", outline="black")
panel.create_oval(335, 325, 355, 355, width=1, fill="white", outline="black")
# boca
panel.create_arc(260, 390, 340, 440, extent=180, style=ARC, start=180, width=2, fill="black", outline="black")
elif seleccion == 5:
panel = Canvas(vs, width=1148, height=700, bg='light blue')
panel.pack()
# casa
panel.create_rectangle(100, 410, 370, 650, width=2, fill='yellow', outline='black')
# tejado
panel.create_polygon(70, 409, 400, 409, 245, 200, width=2, fill='red', outline='black')
# ventanas
panel.create_rectangle(120, 420, 200, 500, width=2, fill='blue', outline='black')
panel.create_rectangle(270, 420, 350, 500, width=2, fill='purple', outline='black')
# Puerta
panel.create_rectangle(200, 550, 260, 650, width=2, fill='red', outline='black')
panel.create_line(230, 550, 230, 650, width=2, fill="black")
panel.create_oval(215, 600, 200, 620, width=2, fill='brown', outline='black')
# pasto
panel.create_rectangle(1, 650, 1147, 700, width=2, fill='green', outline='black')
# arbol
panel.create_rectangle(600, 410, 570, 650, width=2, fill='brown', outline='black')
panel.create_oval(700, 550, 480, 350, width=2, fill='green', outline='black')
# sol
panel.create_oval(1000, 150, 880, 50, width=2, fill='yellow', outline='black')
panel.create_line(900, 200, 1000, 1, width=10, fill="yellow")
panel.create_line(780, 125, 1100, 70, width=10, fill="yellow")
panel.create_line(1050, 200, 880, 10, width=10, fill="yellow")
elif seleccion == 6:
panel = Canvas(vs, width=200, height=200, bg="gray")
panel.pack()
# Primera parte negra
panel.create_polygon(70, 50, 70, 60, 50, 60, 50, 70, 40, 70, 40, 150, 50, 150, 50, 160, 60, 160, 60, 170, 80,
170, 80, 180,
110, 180, 110, 170, 130, 170, 130, 160, 140, 160, 140, 150, 150, 150, 150, 70,
140, 70, 140, 60, 120, 60, 120, 50, 70, 50, width=1, fill="black")
# ojo 1
panel.create_polygon(50, 80, 50, 120, 60, 120, 60, 130, 80, 130, 80, 120, 90, 120, 90, 110, 80, 110, 80, 100,
70, 100, 70, 90
, 60, 90, 60, 80, 50, 80, width=1, fill="white")
# ojo 2
panel.create_polygon(140, 80, 130, 80, 130, 90, 120, 90, 120, 100, 110, 100, 110, 110, 100, 110, 100, 120, 110,
130, 130, 130, 130, 120
, 140, 120, 140, 80, 130, 80, width=1, fill="white")
elif seleccion == 7:
panel = Canvas(vs, width=200, height=200, bg="yellow")
panel.pack()
# Parte negra
panel.create_polygon(70, 10, 130, 10, 130, 20, 150, 20, 150, 30, 160, 30, 160, 50, 170, 50, 170, 60, 180, 60,
180, 130,
170, 130, 170, 140, 160, 140, 160, 160, 150, 160, 150, 170, 50, 170, 50, 160, 40, 160, 40,
140, 30, 140, 30, 130, 20, 130,
20, 60, 30, 60, 30, 50, 40, 50, 40, 30, 50, 30, 50, 20, 70, 20, 70, 10, width=1,
fill="black", outline="black")
# Primera parte blanca
panel.create_polygon(80, 20, 120, 20, 120, 30, 140, 30, 140, 40, 150, 40, 150, 60, 160, 60, 160, 70, 170, 70,
170, 120, 150, 120, 150, 110, 50, 110, 50, 120, 30, 120, 30, 70, 40, 70, 40, 60, 50, 60,
50, 40, 60, 40, 60, 30, 80, 30, 80, 20, width=1, fill="white", outline="white")
# segunda parte blanca
panel.create_polygon(60, 120, 140, 120, 140, 130, 150, 130, 150, 150, 140, 150, 140, 160, 60, 160, 60, 150,
50, 150, 50, 130, 60, 130, 60, 120, width=1, fill="white", outline="white")
# ojos
panel.create_rectangle(80, 120, 90, 140, width=1, fill="black", outline="black")
panel.create_rectangle(110, 120, 120, 140, width=1, fill="black", outline="black")
# manchas
panel.create_polygon(80, 70, 120, 70, 120, 80, 130, 80, 130, 100, 120, 100, 120, 110, 80, 110, 80, 100, 70, 100,
70, 80, 80, 80, 80, 70, width=1, fill="red", outline="red")
panel.create_polygon(110, 20, 120, 20, 120, 30, 140, 30, 140, 50, 120, 50, 120, 40, 110, 40, 110, 20, width=1,
fill="red", outline="red")
panel.create_polygon(80, 20, 90, 20, 90, 40, 80, 40, 80, 50, 60, 50, 60, 30, 80, 30, 80, 20, width=1,
fill="red", outline="red")
panel.create_polygon(40, 60, 60, 60, 60, 90, 50, 90, 50, 100, 30, 100, 30, 70, 40, 70, 40, 60, width=1,
fill="red", outline="red")
panel.create_polygon(140, 60, 160, 60, 160, 70, 170, 70, 170, 100, 150, 100, 150, 90, 140, 90, 140, 60, width=1,
fill="red", outline="red")
elif seleccion == 8:
panel = Canvas(vs, width=400, height=400, bg='red')
panel.pack()
panel.create_polygon(60, 120, 100, 180, 140, 120, 100, 60, width=5, fill='blue',
outline='green') # coordenadas de x1,y1,x2,y2 etc etc y caracteristicas de las figura
elif seleccion == 9:
canvas = Canvas(vs, width=500, height=500, bg="white")
canvas.pack()
canvas.create_polygon(42, 372, 9, 396, -5, 415, -5, 502, 505, 505, 505, 396, 453, 372,
fill="BLUE", outline="black", width=2)
canvas.create_polygon(177, 261, 173, 293, 174, 323, 179, 329, 174, 323, 174, 312, 140, 323, 124, 335, 150, 420,
346, 435, 383, 341, 363, 324, 326, 312, 327, 312, 319, 340, 327, 312, 323, 268,
fill="peach puff", outline="black", width=2)
canvas.create_polygon(119, 337, 157, 340, 183, 356, 198, 382, 110, 381,
fill="peach puff", outline="black", width=2)
canvas.create_polygon(365, 337, 325, 340, 301, 356, 282, 382, 367, 381,
fill="peach puff", outline="black", width=2)
canvas.create_polygon(137, 365, 181, 363, 229, 369, 249, 382, 252, 403, 249, 382, 260, 373, 297, 365, 362, 367,
368, 482, 98, 482,
fill="peach puff", outline="black", width=2)
canvas.create_polygon(114, 353, 212, 399, 269, 401, 369, 355, 350, 484, 127, 482,
fill="blue", outline="black", width=2)
canvas.create_polygon(138, 325, 119, 319, 136, 373, 183, 422, 237, 460, 267, 457, 335, 399, 367, 331, 369, 313,
361, 319, 369, 313, 440, 347, 433, 382, 439, 353,
474, 372, 431, 502, 85, 502, 32, 374, 68, 357, 75, 375,
67, 357, 68, 346, 119, 319,
fill="orange", outline="black", width=2)
canvas.create_polygon(196, 306, 215, 334, 230, 353, 215, 334,
fill="peach puff", outline="black", width=2)
canvas.create_polygon(304, 306, 289, 334, 270, 353, 289, 334,
fill="peach puff", outline="black", width=2)
canvas.create_polygon(184, 260, 117, 276, 80, 305, 106, 254, 127, 233, 79, 232, 44, 249, 71, 203, 112, 184, 82,
165, 24, 165, 84, 125, 144, 108, 134, 55, 91, 1, 206, 43, 240, 89, 268, 88,
311, 103, 336, 130, 372, 132, 423, 170, 396, 170, 374, 177, 403, 203, 419, 232, 400, 224,
376, 224, 398, 246, 376, 241, 334, 243, 344, 239, 353, 250, 364, 271, 342, 261, 323, 260
)
canvas.create_oval(340, 445, 390, 495, fill="white", outline="black", width=2)
canvas.create_polygon(180, 260,
155, 244,
143, 208,
155, 193,
165, 195, fill="peach puff", outline="black", width=2)
canvas.create_polygon(320, 260,
345, 244,
357, 208,
345, 193,
335, 195, fill="peach puff", outline="black", width=2)
canvas.create_polygon(240, 325,
180, 275,
160, 170,
330, 170,
340, 190,
320, 275,
260, 325, fill="peach puff", outline="black", width=2)
canvas.create_polygon(250, 255,
250, 275,
260, 275,
250, 280,
240, 275, fill="peach puff3", outline="black", width=2)
canvas.create_polygon(235, 290,
260, 287,
265, 290,
260, 287, outline="black", width=2)
canvas.create_polygon(237, 247,
233, 253,
200, 245,
190, 195, fill="white", outline="black", width=2)
canvas.create_oval(210, 223.5,
230, 243, fill="black")
canvas.create_polygon(240, 250,
242, 235,
242, 243,
180, 180,
180, 200,
fill="black", outline="black", width=2)
canvas.create_polygon(263, 247,
267, 253,
300, 245,
310, 195, fill="white", outline="black", width=2)
canvas.create_oval(290, 223.5,
270, 243, fill="black")
canvas.create_polygon(260, 250,
257, 235,
258, 243,
320, 180,
320, 200,
fill="black", outline="black", width=2)
canvas.create_polygon(280, 160,
240, 220,
225, 265,
215, 180,
220, 160,
223, 183,
190, 200,
170, 250,
155, 170,
210, 160)
canvas.create_polygon(266, 174,
296, 206, 311, 245, 321, 204, 313, 156, 256, 121, 220, 174)
canvas.create_polygon(313, 184, 327, 200, 332, 226, 342, 198, 331, 149, 305, 128, 256, 125)
elif seleccion == 10:
poligono = Canvas(vs, width=400, height=400, bg="gray")
poligono.create_polygon(130, 20, 60, 80, 100, 140, 160, 140, 200, 80, width=3, fill="pink", outline="black")
poligono.pack()
elif seleccion == 11:
panel = Canvas(vs, width=500, height=400, bg='white')
panel.pack()
panel.create_polygon(140, 40, 300, 40, 400, 140, 40, 140, width=5, fill='white', outline='black')
# coordenadas y caracteristica de la figura
elif seleccion == 12:
panel = Canvas(vs, width=225, height=200, bg="white")
panel.pack()
# Parte negra
panel.create_polygon(70, 10, 170, 10, 170, 20, 190, 20, 190, 30, 200, 30, 200, 80, 190, 80, 190, 90, 170, 90,
170, 100, 140, 100, 140, 120, 150, 120, 150, 110, 170, 110, 170, 100, 190, 100, 190, 110,
200, 110, 200, 140, 190, 140, 190, 150, 180, 150, 180, 160, 160, 160, 160, 170, 80, 170,
80, 160, 60, 160, 60, 150, 50, 150, 50, 140, 40, 140, 40, 110, 50, 110, 50, 100, 70, 100,
70, 110, 90, 110, 90, 120, 100, 120, 100, 100, 70, 100, 70, 90, 50, 90, 50, 80, 40, 80, 40,
30, 50, 30, 50, 20, 70, 20, 70, 10, width=1, fill="black", outline="black")
# Parte naranja
panel.create_polygon(80, 20, 160, 20, 160, 30, 180, 30, 180, 40, 190, 40, 190, 70, 180, 70, 180, 80, 160, 80,
160, 90, 80, 90, 80, 80, 60, 80, 60, 70, 50, 70, 50, 40, 60, 40, 60, 30, 80, 30, 80, 20,
width=1, fill="orange", outline="orange")
# Parte amarilla
panel.create_polygon(90, 30, 150, 30, 150, 40, 170, 40, 170, 70, 150, 70, 150, 80, 90, 80, 90, 70, 70, 70, 70,
40, 90, 40, 90, 30, width=1, fill="yellow", outline="yellow")
# Parte blanca
panel.create_polygon(90, 50, 150, 50, 150, 60, 90, 60, 90, 50, width=1, fill="white", outline="white")
# Ojos rectangulos negros
panel.create_rectangle(100, 40, 110, 70, width=1, fill="black", outline="black")
panel.create_rectangle(130, 40, 140, 70, width=1, fill="black", outline="black")
# Parte verde
panel.create_polygon(110, 100, 130, 100, 130, 150, 140, 150, 140, 130, 150, 130, 150, 120, 170, 120, 170, 110,
190, 110, 190, 140, 180, 140, 180, 150, 160, 150, 160, 160, 80, 160, 80, 150, 60, 150, 60,
140, 50, 140, 50, 110, 70, 110, 70, 120, 90, 120, 90, 130, 100, 130, 100, 150, 110, 150,
110, 100, width=1, fill="green", outline="green")
elif seleccion == 13:
panel = Canvas(vs, width=300, height=200, bg="black")
panel.pack()
# Cuerpo del fantasma
panel.create_polygon(100, 10, 130, 10, 130, 20, 150, 20, 150, 20, 150, 30, 160, 30, 160, 40, 170, 40, 170, 60,
180, 60, 180, 160, 170, 160,
170, 150, 160, 150, 160, 140, 150, 140, 150, 150, 140, 150, 140, 160, 130, 160, 130, 140,
100, 140, 100, 160,
90, 160, 90, 150, 80, 150, 80, 140, 70, 140, 70, 150, 60, 150, 60, 160, 50, 160, 50, 60,
60, 60,
60, 40, 70, 40, 70, 30, 80, 30, 80, 20, 100, 20, width=1, fill="blue", outline="white")
# Ojos Fantasma
panel.create_polygon(80, 50, 100, 50, 100, 70, 80, 70, width=1, fill="white")
panel.create_polygon(130, 50, 150, 50, 150, 70, 130, 70, width=1, fill="white")
# Boca Fantasma
panel.create_polygon(65, 110, 70, 110, 70, 120, 65, 120, width=1, fill="white")
panel.create_polygon(70, 100, 90, 100, 90, 110, 70, 110, width=1, fill="white")
panel.create_polygon(90, 110, 110, 110, 110, 120, 90, 120, width=1, fill="white")
panel.create_polygon(110, 100, 130, 100, 130, 110, 110, 110, width=1, fill="white")
panel.create_polygon(130, 110, 150, 110, 150, 120, 130, 120, width=1, fill="white")
panel.create_polygon(150, 100, 170, 100, 170, 110, 150, 110, width=1, fill="white")
panel.create_polygon(170, 110, 175, 110, 175, 120, 170, 120, width=1, fill="white")
elif seleccion == 14:
Escudo = Canvas(vs, width=420, height=420, bg='blue')
# Primer Arco Rojo
Escudo.create_oval(40, 40, 400, 400, width=7, fill='red')
# Arco Gris
Escudo.create_oval(90, 90, 350, 350, width=7, fill='grey')
# Segundo Arco Rojo
Escudo.create_oval(140, 140, 302, 302, width=7, fill='red')
# Arco Azul
Escudo.create_oval(163, 163, 278, 278, width=7, fill='blue')
# Estrella Blanca
Escudo.create_polygon(222, 170,
250, 268,
170, 200,
270, 200,
185, 268, width=5, fill="white", outline="white")
Escudo.pack() # para que pueda aparecer el Escudo
elif seleccion == 15:
circulo = Canvas(vs, width=210, height=210, bg='magenta')
circulo.pack()
circulo.create_oval(20, 20, 200, 200, width=10, fill='yellow')
circulo.create_oval(90, 92, 70, 70, width=10, fill='black')
circulo.create_oval(140, 70, 160, 92, width=10, fill='black')
circulo.create_oval(140, 155, 90, 110, width=10, fill='black')
elif seleccion == 16:
dib = Canvas(vs, width=800, height=800, bg="cyan")
dib.pack(expand=YES, fill=BOTH)
# gorra
dib.create_polygon(250, 0, 250, 50, 200, 50, 200, 100, 650, 100, 650, 50, 500, 50, 500, 0, width=1, fill="red",
outline="black")
# cabelloenJota
dib.create_polygon(200, 100, 200, 150, 250, 150, 250, 250, 350, 250, 350, 200, 300, 200, 300, 150, 350, 150,
350, 100, width=1, fill="brown", outline="black")
# oreja
dib.create_polygon(200, 150, 200, 250, 250, 250, 250, 150, width=1, fill="yellow", outline="black")
# cabellodetrasoreja
dib.create_polygon(200, 150, 150, 150, 150, 250, 200, 250, 200, 150, width=1, fill="brown", outline="black")
# cabellobajooreja
dib.create_polygon(200, 250, 200, 300, 250, 300, 250, 250, width=1, fill="brown", outline="black")
# cara
dib.create_polygon(350, 100, 350, 150, 300, 150, 300, 200, 350, 200, 350, 250, 250, 250, 250, 350, 550, 350,
550, 250, 700, 250, 700, 200, 650, 200, 650, 150, 550, 150, 550, 100, 350, 100, width=1,
fill="yellow", outline="black")
# ojo
dib.create_polygon(450, 100, 450, 200, 500, 200, 500, 100)
# Mostacho
dib.create_polygon(500, 200, 500, 250, 450, 250, 450, 300, 650, 300, 650, 250, 550, 250, 550, 200)
# Mangaizquierda
dib.create_polygon(300, 350, 200, 350, 200, 400, 150, 400, 150, 450, 100, 450, 100, 500, 200, 500, 200, 550,
250, 550, 250, 500, 300, 500, 300, 350, width=1, fill="red", outline="black")
# centro
dib.create_polygon(350, 350, 350, 450, 450, 450, 450, 350, width=1, fill="red", outline="black")
# Mangaderecha
dib.create_polygon(500, 350, 500, 500, 550, 500, 550, 550, 600, 550, 600, 500, 700, 500, 700, 450, 650, 450,
650, 400, 600, 400, 600, 350, width=1, fill="red", outline="black")
# Manoizquierda
dib.create_polygon(100, 500, 100, 650, 200, 650, 200, 600, 250, 600, 250, 550, 200, 550, 200, 500, width=1,
fill="yellow", outline="black")
# Manoderecha
dib.create_polygon(600, 500, 600, 550, 550, 550, 550, 600, 600, 600, 600, 650, 700, 650, 700, 500, width=1,
fill="yellow", outline="black")
# ropita
dib.create_polygon(300, 350, 300, 500, 250, 500, 250, 600, 200, 600, 200, 700, 350, 700, 350, 650, 450, 650,
450, 700, 600, 700, 600, 600, 550, 600, 550, 500, 500, 500, 500, 350, 450, 350, 450, 450,
350, 450, 350, 350, width=1, fill="blue", outline="black")
# botonizquierdo
dib.create_polygon(300, 500, 300, 550, 350, 550, 350, 500, width=1, fill="yellow", outline="black")
# botonderecho
dib.create_polygon(450, 500, 450, 550, 500, 550, 500, 500, width=1, fill="yellow", outline="black")
# botaizquierda
dib.create_polygon(150, 700, 150, 750, 100, 750, 100, 800, 300, 800, 300, 700, width=1, fill="brown",
outline="black")
# botaderecha
dib.create_polygon(500, 700, 500, 800, 700, 800, 700, 750, 650, 750, 650, 700, width=1, fill="brown",
outline="black")
elif seleccion == 17:
bat = Canvas(vs, width=280, height=280, bg="blue")
bat.pack(expand=YES, fill=BOTH)
# Mascara
bat.create_polygon(80, 20, 60, 20, 60, 160, 80, 160, 80, 180, 180, 180, 180, 160, 200, 160, 200, 20, 180, 20,
180, 40, 160, 40, 160, 60, 100, 60, 100, 40, 80, 40, 80, 20)
# ojoizquierdo
bat.create_polygon(100, 100, 100, 120, 120, 120, 120, 100, width=1, fill="white", outline="black")
# ojoderecho
bat.create_polygon(140, 100, 140, 120, 160, 120, 160, 100, width=1, fill="white", outline="black")
# boca
bat.create_polygon(80, 140, 80, 160, 180, 160, 180, 140, width=1, fill="pink", outline="black")
# brazos
bat.create_polygon(80, 160, 40, 160, 40, 200, 220, 200, 220, 160, 180, 160, 180, 180, 80, 180, width=1,
fill="gray", outline="black")
# capa
bat.create_polygon(60, 200, 60, 260, 80, 260, 80, 220, 180, 220, 180, 260, 200, 260, 200, 200)
# cinturon
bat.create_polygon(120, 200, 120, 220, 140, 220, 140, 200, width=1, fill="yellow", outline="black")
# piernas
bat.create_polygon(80, 220, 80, 260, 120, 260, 120, 240, 140, 240, 140, 260, 180, 260, 180, 220, width=1,
fill="gray", outline="black")
# restocapa
bat.create_polygon(120, 240, 120, 260, 140, 260, 140, 240)
elif seleccion == 18:
Space = Canvas(vs, width=800, height=500, bg="RED")
Space.pack(expand=YES, fill=BOTH)
Space.create_polygon(250, 50, 200, 50, 200, 100, 250, 100, 250, 150, 200, 150, 200, 200, 150, 200, 150, 250,
100, 250, 100, 400, 150, 400,
150, 300, 200, 300, 200, 450, 350, 450, 350, 400, 250, 400, 250, 350, 500, 350, 500, 400,
400, 400, 400, 450, 550, 450, 550, 300, 600, 300, 600, 400,
650, 400, 650, 250, 600, 250, 600, 200, 550, 200, 550, 150, 500, 150, 500, 100, 550, 100,
550, 50, 450, 50, 450, 150, 300, 150, 300, 50, fill="green", outline="blue", width=6)
Space.create_polygon(250, 200, 250, 250, 300, 250, 300, 200, fill="white", outline="white", width=6)
Space.create_polygon(500, 200, 450, 200, 450, 250, 500, 250, fill="white", outline="white", width=6)
elif seleccion == 19:
canvas = Canvas(vs, width=500, height=800, bg="White")
canvas.pack()
canvas.create_arc(100, 100, 400, 400, start=0, extent=180, fill="green", outline="green")
canvas.create_oval(175, 150, 200, 175, fill="white", outline="white")
canvas.create_oval(300, 150, 325, 175, fill="white", outline="white")
canvas.create_oval(100, 550, 200, 450, fill="green", outline="green")
canvas.create_polygon(100, 260, 100, 500, 150, 550, 350, 550, 400, 500, 400, 260, fill="green", outline="green")
canvas.create_oval(300, 550, 400, 450, fill="green", outline="green")
canvas.create_polygon(160, 550, 160, 625, 220, 625, 220, 550, fill="green", outline="green")
canvas.create_polygon(280, 550, 280, 625, 340, 625, 340, 550, fill="green", outline="green")
canvas.create_oval(160, 600, 220, 650, fill="green", outline="green")
canvas.create_oval(280, 600, 340, 650, fill="green", outline="green")
canvas.create_polygon(30, 275, 30, 450, 90, 450, 90, 275, fill="green", outline="green")
canvas.create_oval(30, 250, 90, 300, fill="green", outline="green")
canvas.create_oval(30, 425, 90, 475, fill="green", outline="green")
canvas.create_polygon(410, 275, 410, 450, 470, 450, 470, 275, fill="green", outline="green")
canvas.create_oval(410, 250, 470, 300, fill="green", outline="green")
canvas.create_oval(410, 425, 470, 475, fill="green", outline="green")
canvas.create_polygon(160, 130,
180, 118,
160, 88,
140, 100, fill="green", outline="green")
canvas.create_oval(141, 85, 163, 110, fill="green", outline="green")
canvas.create_polygon(335, 130,
315, 118,
335, 88,
355, 100, fill="green", outline="green")
canvas.create_oval(354, 85, 332, 110, fill="green", outline="green")
def funcion_main():
vp = Tk()
vp.geometry("300x800+5+5")
vp.configure(bg="black")
vp.title("Poligonos grupo A")
boton1 = Button(vp, text="Perrito", bg="blue", fg="White",
command=lambda: funcion(1, "Programa por Ambrocio Laureano"))
boton1.pack(padx=5, pady=5, fill=X)
boton2 = Button(vp, text="Angry Bird", bg="blue", fg="White",
command=lambda: funcion(2, "Programa por Griselda Maldonado"))
boton2.pack(padx=5, pady=5, fill=X)
boton3 = Button(vp, text="Girasol", bg="blue", fg="White",
command=lambda: funcion(3, "Programa por Griselda Maldonado"))
boton3.pack(padx=5, pady=5, fill=X)
boton4 = Button(vp, text="Hongo", bg="blue", fg="White",
command=lambda: funcion(4, "Programa por Griselda Maldonado"))
boton4.pack(padx=5, pady=5, fill=X)
boton5 = Button(vp, text="Paisaje", bg="blue", fg="White",
command=lambda: funcion(5, "Programa por Manuel Ramirez"))
boton5.pack(padx=5, pady=5, fill=X)
boton6 = Button(vp, text="Venom", bg="blue", fg="White",
command=lambda: funcion(6, "Programa por Livan Sanchez"))
boton6.pack(padx=5, pady=5, fill=X)
boton7 = Button(vp, text="Seta", bg="blue", fg="White",
command=lambda: funcion(7, "Programa por Carolina Sauceda"))
boton7.pack(padx=5, pady=5, fill=X)
boton8 = Button(vp, text="Rombo", bg="blue", fg="White",
command=lambda: funcion(8, "Programa por Carlos Olvera"))
boton8.pack(padx=5, pady=5, fill=X)
boton9 = Button(vp, text="Goku", bg="blue", fg="White",
command=lambda: funcion(9, "Programa por Santiago Lopez"))
boton9.pack(padx=5, pady=5, fill=X)
boton10 = Button(vp, text="Pentagono", bg="blue", fg="White",
command=lambda: funcion(10, "Programa por Alondra Adamary"))
boton10.pack(padx=5, pady=5, fill=X)
boton11 = Button(vp, text="Cuadrilatero", bg="blue", fg="White",
command=lambda: funcion(11, "Programa por Rocio Mahe"))
boton11.pack(padx=5, pady=5, fill=X)
boton12 = Button(vp, text="Flor", bg="blue", fg="White",
command=lambda: funcion(12, "Programa por Lyvan Lumbreras"))
boton12.pack(padx=5, pady=5, fill=X)
boton13 = Button(vp, text="Fantasma", bg="blue", fg="White",
command=lambda: funcion(13, "Programa por Fernando Veliz"))
boton13.pack(padx=5, pady=5, fill=X)
boton14 = Button(vp, text="Escudo", bg="blue", fg="White",
command=lambda: funcion(14, "Programa por Jesus Uribe"))
boton14.pack(padx=5, pady=5, fill=X)
boton15 = Button(vp, text="Carita", bg="blue", fg="White",
command=lambda: funcion(15, "Programa por Diana Lucia"))
boton15.pack(padx=5, pady=5, fill=X)
boton16 = Button(vp, text="Mario Bros", bg="blue", fg="White",
command=lambda: funcion(16, "Programa por Alejandro Echavarria"))
boton16.pack(padx=5, pady=5, fill=X)
boton17 = Button(vp, text="Batman", bg="blue", fg="White",
command=lambda: funcion(17, "Programa por Alejandro Echavarria"))
boton17.pack(padx=5, pady=5, fill=X)
boton18 = Button(vp, text="Arcade", bg="blue", fg="White",
command=lambda: funcion(18, "Programa por Jaziel Martinez"))
boton18.pack(padx=5, pady=5, fill=X)
boton19 = Button(vp, text="Android", bg="blue", fg="White",
command=lambda: funcion(19, "Programa por Ivan Gutierrez"))
boton19.pack(padx=5, pady=5, fill=X)
vp.mainloop()
funcion_main()
lunes, 18 de febrero de 2019
Ejemplo While
import math
def calculo():
opc2=1
while opc2 !=4:
opc=0
print "Menu de opciones"
print "Seleccione la opcion"
print "1.- Determinar si el numero es par"
print "2.- Sacar seno y coseno de dos numeros"
print "3.- Logaritmo de un numero"
print "4.- Salir"
opc = int(input("Opcion:"))
if opc==1:
print "Ingrese un valor:"
a = int(input())
residuo = a % 2
if residuo == 0:
print "Es un numero par"
else:
print "Es un numero impar"
elif opc==2:
a = int(input("Ingrese un valor:"))
b = int(input("Ingrese otro valor:"))
# procedimiento de la maestra Zzz..
sin1 = math.sin(a)
cos1 = math.cos(a)
sin2 = math.sin(b)
cos2 = math.cos(b)
#print "Seno del valor 1: ", sin1
#print "Coseno del valor 1: ", cos1
#print "Seno del valor 2: ", sin2
# print "Coseno del valor 2: ", cos2
# procedimiento mio :p
print "El coseno del valor 1 es: ", math.cos(a)
print "El seno del valor 1 es: ", math.sin(a)
print "El coseno del valor 2 es: ", math.cos(b)
print "El seno del valor 2 es: ", math.sin(b)
elif opc==3:
a = int(input("Ingrese un valor para logaritmo: "))
print "El logaritmo del valor es: ", math.log10(a)
else:
opc2=4
Librerias Python
import math
print "Ingrese el valor de un cateto:"
a = int (input(""))
print "Ingrese el valor del otro cateto:"
b = int ( input(""))
res = math.hypot(a, b)
print "La hipotenusa del triangulo es: " , res
Ejemplo IF
import time
h= input("Introduzca un numero:")
if h%2 == 0 :
print "Es numero par"
else:
print "Es numero impar"
martes, 30 de octubre de 2018
programa figuras:
from Tkinter import * #uso esta lib para la GUIfrom
from PIL import Image,ImageTk # la uso para desplegar la imagen
import os #para poder usar carpetas, dando la ruta
import random # uso para generar numeros aleatorios
import pygame #ayuda a reproducir sonido mp3,ogg
import time #sleep para dormir la compu unos seg..
import threading # libreria para manejar hilos
dir= os.path.dirname(__file__)
fotos= dir + "/imagenes/"
sonidos = dir + "/sonidos2/"
root=Tk() #para la ventana de app tkinter
root.geometry("500x500")
arreglo= [1]
eleccion_aleatoria = str(arreglo.index(random.choice(arreglo))+ 1)
print eleccion_aleatoria
figura= fotos + eleccion_aleatoria + ".png"
print figura
#para reproducir sonido
sonido = sonidos + "s_(" + eleccion_aleatoria + ").mp3"
print sonido
pygame.mixer.init()
pygame.mixer.music.load(sonido)#abre el archivo
pygame.mixer.music.play()#repod sonido
img = Image.open(figura) #abriendo el archivo figura
tkimage= ImageTk.PhotoImage(img)
'crear un Label de tkinter para desplegar la imagen'
lab = Label(root,image=tkimage)
lab.pack()
pygame.init()
root.mainloop()
miércoles, 24 de octubre de 2018
jueves, 4 de octubre de 2018
Poligonos en un Menu:
from Tkinter import *
def ocultar(ventana):ventana.destroy()
def ejecutar(f): v0.after(200, f)
def antilope():
v1 = Toplevel(v0)
v1.title("Ventana hija")
v1.protocol("WM_DELETE_WINDOW", "onexit")
v1.config(bg="black")
v1.geometry("500x500")
canvas = Canvas(v1, width=390, height=350, bg='black')
canvas.pack(expand=YES, fill=BOTH)
canvas.create_polygon(52.5, 14.5, 37, 59.1, 51, 59.1, fill="#5C554E", outline="#5C554E", width=1)
canvas.create_polygon(19.3, 56.8, 58, 59.1, 67, 91, 37.5, 83, fill="#C3BAB5", outline="#C3BAB5", width=1)
canvas.create_polygon(58, 57.8, 78, 77, 71, 103, fill="#D4CCC1", outline="#D4CCC1", width=1)
canvas.create_polygon(37.5, 83, 67.4, 91, 71, 103, fill="#998C8A", outline="#998C8A", width=1)
canvas.create_polygon(71, 103, 71, 104.8, 59.1, 104.8, 53.2, 91, fill="#665B57", outline="#665B57", width=1)
canvas.create_polygon(86, 105.6, 98.2, 148.6, 47, 133.6, 24.2, 103.6, fill="#C3BAB5", outline="#C3BAB5",
width=1)
canvas.create_polygon(98.2, 148.6, 102, 165.2, 47, 133.6, fill="#9B8D8A", outline="#9B8D8A", width=1)
canvas.create_polygon(86, 105.6, 124, 169, 120, 196, 110.8, 196, fill="#D5CDC2", outline="#D5CDC2", width=1)
canvas.create_polygon(102, 165.2, 110.8, 196, 99, 196, 80.6, 153, fill="#605550", outline="#605550", width=1)
canvas.create_polygon(139.5, 197, 147, 241, 71, 220.4, 46, 193, fill="#C3BAB5", outline="#C3BAB5", width=1)
canvas.create_polygon(147, 241, 150, 261.4, 71, 220.4, fill="#968B87", outline="#968B87", width=1)
canvas.create_polygon(139.5, 197, 193, 274.2, 189, 307.8, 176, 321, 161.6, 321, fill="#D4CCC1",
outline="#D4CCC1", width=1)
canvas.create_polygon(150, 261.4, 161.6, 321, 126.8, 249, fill="#605551", outline="#605551", width=1)
canvas.create_polygon(199.4, 307.8, 189, 307.8, 176, 321, 186.6, 461, 184, 448.8, 171, 479.5, 199.4, 503,
fill="#C2AD9C", outline="#C2AD9C", width=1)
canvas.create_polygon(176, 321, 161.6, 321, 186.6, 461, fill="#615652", outline="#615652", width=1)
canvas.create_polygon(161.6, 321, 136, 359.4, 177.2, 409, fill="#D9C6B7", outline="#D9C6B7", width=1)
canvas.create_polygon(144.4, 369.8, 139.6, 384.6, 160, 389.4, fill="#443232", outline="#443232", width=1)
canvas.create_polygon(139.6, 384.6, 160, 389.4, 177.2, 409, 169.2, 450, fill="#826E65", outline="#826E65",
width=1)
canvas.create_polygon(171, 479.5, 180.6, 497.8, 191.2, 496.8, fill="#463334", outline="#463334", width=1)
canvas.create_polygon(177.2, 409, 164.8, 475, 176.5, 511, 199.4, 522, 199.4, 502.8, 191.2, 496.8, 180.6, 497.8,
171, 479.5, 184, 448.8, fill="#9B7F79", outline="#9B7F79", width=1)
canvas.create_polygon(151.8, 335.4, 109.6, 280, 142.2, 349.2, fill="#5F5150", outline="#5F5150", width=1)
canvas.create_polygon(109.6, 280, 70.3, 266, 94.3, 329, 131.3, 326, fill="#483636", outline="#483636", width=1)
canvas.create_polygon(94.3, 329, 137, 336, 132, 326.8, fill="#C2AF9D", outline="#C2AF9D", width=1)
canvas.create_polygon(115, 333, 136, 359.4, 142.2, 349.2, 137, 336, fill="#826E65", outline="#826E65", width=1)
canvas.create_polygon(346.5, 14.5, 347.5, 59.1, 361, 59.1, fill="#2E2621", outline="#2E2621", width=1)
canvas.create_polygon(379.4, 56.8, 341.8, 59.1, 332, 91, 361, 83, fill="#908782", outline="#908782", width=1)
canvas.create_polygon(341.5, 57.8, 324, 75, 327.6, 103, fill="#A29B8F", outline="#A29B8F", width=1)
canvas.create_polygon(361, 83, 332.4, 91, 329, 103, fill="#685D59", outline="#685D59", width=1)
canvas.create_polygon(329, 103, 326.8, 104.8, 340, 104.8, 345.6, 91, fill="#2D2220", outline="#2D2220", width=1)
canvas.create_polygon(313, 105.6, 301, 148.6, 352, 133.6, 374.5, 103.6, fill="#908782", outline="#908782",
width=1)
canvas.create_polygon(301, 148.6, 297, 165.2, 352, 133.6, fill="#625755", outline="#625755", width=1)
canvas.create_polygon(313, 105.6, 274, 169, 279, 196, 288, 196, fill="#A1998E", outline="#A1998E", width=1)
canvas.create_polygon(297, 165.2, 288, 196, 300, 196, 318, 153, fill="#2D221E", outline="#2D221E", width=1)
canvas.create_polygon(260, 197, 252, 241, 331, 220.4, 352.4, 193, fill="#908782", outline="#908782", width=1)
canvas.create_polygon(252, 241, 249, 261.4, 331, 220.4, fill="#645955", outline="#645955", width=1)
canvas.create_polygon(260, 197, 205, 274.2, 209.8, 307.8, 223, 321, 238, 321, fill="#A1998E", outline="#A1998E",
width=1)
canvas.create_polygon(249, 261.4, 238.6, 321, 271.8, 249, fill="#2D221E", outline="#2D221E", width=1)
canvas.create_polygon(199.4, 307.8, 209.8, 307.8, 223, 321, 212.6, 461, 215, 448.8, 228, 479.5, 199.4, 503,
fill="#8E7968", outline="#8E7968", width=1)
canvas.create_polygon(223, 321, 238.6, 321, 212.6, 461, fill="#302722", outline="#302722", width=1)
canvas.create_polygon(238, 321, 262.8, 359.4, 222.5, 409, fill="#A69384", outline="#A69384", width=1)
canvas.create_polygon(254.4, 369.8, 259.6, 384.6, 238, 389.4, fill="#120001", outline="#120001", width=1)
canvas.create_polygon(259.6, 384.6, 238, 389.4, 222.5, 409, 229.5, 450, fill="#4F3B32", outline="#4F3B32",
width=1)
canvas.create_polygon(228, 479.5, 218.3, 497.8, 207.5, 496.8, fill="#180A04", outline="#180A04", width=1)
canvas.create_polygon(222.5, 409, 234, 475, 223, 511, 199.4, 522, 199.4, 502.8, 207.5, 496.8, 218.3, 497.8, 228,
479.5, 215, 448.8, fill="#674C45", outline="#674C45", width=1)
canvas.create_polygon(247, 335.4, 290.6, 280, 256.8, 349.2, fill="#281F1D", outline="#281F1D", width=1)
canvas.create_polygon(290.6, 280, 328, 266, 304.8, 329, 267.5, 326, fill="#140202", outline="#140202", width=1)
canvas.create_polygon(304.8, 329, 262.5, 336, 267.5, 326.8, fill="#8D7B66", outline="#8D7B66", width=1)
canvas.create_polygon(283, 333, 262.8, 359.4, 256.8, 349.2, 262.5, 336, fill="#4D3930", outline="#4D3930",
width=1)
b3 = Button(canvas, text="ocultar poligono de David Mendoza Martinez", command=lambda: ejecutar(ocultar(v1)))
b3.grid(row=1, column=3)
v1.deiconify()
def gato():
v1 = Toplevel(v0)
v1.title("Ventana hija")
v1.protocol("WM_DELETE_WINDOW", "onexit")
v1.config(bg="black")
v1.geometry("500x500")
canvas = Canvas(v1, width=300, height=200, bg='white')
canvas.pack(expand=YES, fill=BOTH)
canvas.create_polygon(420, 180,
420, 60,
380, 100,
300, 100,
260, 60,
260, 140,
220, 100,
180, 100,
140, 140,
140, 80,
150, 80,
200, 40,
200, 20,
160, 20,
90, 80,
100, 160,
120, 270,
200, 270,
200, 230,
160, 230,
160, 210,
180, 190,
220, 190,
220, 270,
280, 270,
280, 230,
260, 230,
260, 180,
400, 200,
360, 220,
320, 220,
280, 180,
fill="lightblue", outline="brown", width=6)
b3 = Button(canvas, text="ocultar Gato de Eduardo Aquino Sanchez", command=lambda: ejecutar(ocultar(v1)))
b3.grid(row=1, column=3)
v1.deiconify()
def flores():
v1 = Toplevel(v0)
v1.title("Ventana hija")
v1.protocol("WM_DELETE_WINDOW", "onexit")
v1.config(bg="black")
v1.geometry("500x500")
figuras = Canvas(v1, width=500, bg='white')
figuras.pack(expand=YES, fill=BOTH)
puntos = [35, 75, 35, 85, 45, 95, 75, 95, 85, 85, 85, 75]
figuras.create_polygon(puntos, fill='brown', outline="black", width=3)
puntos2 = [50, 75, 50, 40, 60, 30, 60, 40, 70, 40, 70, 30, 80, 30, 80, 20, 70, 20, 70, 10, 60, 10, 60, 20, 50, 20,
50, 30, 60, 30, 50, 40]
b6 = Button(figuras, text="Cerrar figura de flores de Michelle Morales", command=lambda: v1.destroy())
figuras.create_polygon(puntos2, fill='white', outline="black", width=2)
puntos3 = [60, 30, 70, 30, 70, 20, 60, 20]
figuras.create_polygon(puntos3, fill='yellow', outline="black", width=2)
puntos4 = [50, 54.5, 55, 53, 57, 53, 70, 54.5, 57, 59, 50, 54.5]
figuras.create_polygon(puntos4, fill='green', outline="black", width=2)
puntos5 = [235, 275, 235, 285, 245, 295, 275, 295, 285, 285, 285, 275]
figuras.create_polygon(puntos5, fill='brown', outline="black", width=3)
puntos6 = [250, 275, 250, 240, 260, 230, 260, 240, 270, 240, 270, 230, 280, 230, 280, 220, 270, 220, 270, 210, 260,
210, 260, 220, 250, 220, 250, 230, 260, 230, 250, 240]
figuras.create_polygon(puntos6, fill='white', outline="black", width=2)
puntos7 = [260, 230, 270, 230, 270, 220, 260, 220]
figuras.create_polygon(puntos7, fill='yellow', outline="black", width=2)
puntos8 = [250, 254.5, 255, 253, 257, 253, 270, 254.5, 257, 259, 250, 254.5]
figuras.create_polygon(puntos8, fill='green', outline="black", width=2)
puntos5 = [135, 175, 135, 185, 145, 195, 175, 195, 185, 185, 185, 175]
figuras.create_polygon(puntos5, fill='brown', outline="black", width=3)
puntos6 = [150, 175, 150, 140, 160, 130, 160, 140, 170, 140, 170, 130, 180, 130, 180, 120, 170, 120, 170, 110, 160,
110, 160, 120, 150, 120, 150, 130, 160, 130, 150, 140]
figuras.create_polygon(puntos6, fill='white', outline="black", width=2)
puntos7 = [160, 130, 170, 130, 170, 120, 160, 120]
figuras.create_polygon(puntos7, fill='yellow', outline="black", width=2)
puntos8 = [150, 154.5, 155, 153, 157, 153, 170, 154.5, 157, 159, 150, 154.5]
figuras.create_polygon(puntos8, fill='green', outline="black", width=2)
puntos5 = [35, 175, 35, 185, 45, 195, 75, 195, 85, 185, 85, 175]
figuras.create_polygon(puntos5, fill='brown', outline="black", width=3)
puntos6 = [50, 175, 50, 140, 60, 130, 60, 140, 70, 140, 70, 130, 80, 130, 80, 120, 70, 120, 70, 110, 60, 110, 60,
120, 50, 120, 50, 130, 60, 130, 50, 140]
figuras.create_polygon(puntos6, fill='white', outline="black", width=2)
puntos7 = [60, 130, 70, 130, 70, 120, 60, 120]
figuras.create_polygon(puntos7, fill='yellow', outline="black", width=2)
puntos8 = [50, 154.5, 55, 153, 57, 153, 70, 154.5, 57, 159, 50, 154.5]
figuras.create_polygon(puntos8, fill='green', outline="black", width=2)
puntos5 = [35, 375, 35, 385, 45, 395, 75, 395, 85, 385, 85, 375]
figuras.create_polygon(puntos5, fill='brown', outline="black", width=3)
puntos6 = [50, 375, 50, 340, 60, 330, 60, 340, 70, 340, 70, 330, 80, 330, 80, 320, 70, 320, 70, 310, 60, 310, 60,
320, 50, 320, 50, 330, 60, 330, 50, 340]
figuras.create_polygon(puntos6, fill='white', outline="black", width=2)
puntos7 = [60, 330, 70, 330, 70, 320, 60, 320]
figuras.create_polygon(puntos7, fill='yellow', outline="black", width=2)
puntos8 = [50, 354.5, 55, 353, 57, 353, 70, 354.5, 57, 359, 50, 354.5]
figuras.create_polygon(puntos8, fill='green', outline="black", width=2)
puntos5 = [35, 275, 35, 285, 45, 295, 75, 295, 85, 285, 85, 275]
figuras.create_polygon(puntos5, fill='brown', outline="black", width=3)
puntos6 = [50, 275, 50, 240, 60, 230, 60, 240, 70, 240, 70, 230, 80, 230, 80, 220, 70, 220, 70, 210, 60, 210, 60,
220, 50, 220, 50, 230, 60, 230, 50, 240]
figuras.create_polygon(puntos6, fill='white', outline="black", width=2)
puntos7 = [60, 230, 70, 230, 70, 220, 60, 220]
figuras.create_polygon(puntos7, fill='yellow', outline="black", width=2)
puntos8 = [50, 254.5, 55, 253, 57, 253, 70, 254.5, 57, 259, 50, 254.5]
figuras.create_polygon(puntos8, fill='green', outline="black", width=2)
puntos5 = [135, 275, 135, 285, 145, 295, 175, 295, 185, 285, 185, 275]
figuras.create_polygon(puntos5, fill='brown', outline="black", width=3)
puntos6 = [150, 275, 150, 240, 160, 230, 160, 240, 170, 240, 170, 230, 180, 230, 180, 220, 170, 220, 170, 210, 160,
210, 160, 220, 150, 220, 150, 230, 160, 230, 150, 240]
figuras.create_polygon(puntos6, fill='white', outline="black", width=2)
puntos7 = [160, 230, 170, 230, 170, 220, 160, 220]
figuras.create_polygon(puntos7, fill='yellow', outline="black", width=2)
puntos8 = [150, 254.5, 155, 253, 157, 253, 170, 254.5, 157, 259, 150, 254.5]
figuras.create_polygon(puntos8, fill='green', outline="black", width=2)
puntos5 = [235, 175, 235, 185, 245, 195, 275, 195, 285, 185, 285, 175]
figuras.create_polygon(puntos5, fill='brown', outline="black", width=3)
puntos6 = [250, 175, 250, 140, 260, 130, 260, 140, 270, 140, 270, 130, 280, 130, 280, 120, 270, 120, 270, 110, 260,
110, 260, 120, 250, 120, 250, 130, 260, 130, 250, 140]
figuras.create_polygon(puntos6, fill='white', outline="black", width=2)
puntos7 = [260, 130, 270, 130, 270, 120, 260, 120]
figuras.create_polygon(puntos7, fill='yellow', outline="black", width=2)
puntos8 = [250, 154.5, 255, 153, 257, 153, 270, 154.5, 257, 159, 250, 154.5]
figuras.create_polygon(puntos8, fill='green', outline="black", width=2)
b6.pack()
v1.deiconify()
v0=Tk()
menu1 = Menu(v0)
v0.config(menu=menu1)
menu1_1 = Menu(menu1, tearoff=0)
menu1.add_cascade(label="Poligonos", menu=menu1_1)
menu1_1_1 = Menu(menu1_1, tearoff=0)
menu1_1.add_cascade(label="Animales", menu=menu1_1_1)
menu1_1_1.add_command(label="Antilope",command=lambda: antilope())
menu1_1_1.add_command(label="Gato",command=lambda: gato())
menu1_2 = Menu(menu1, tearoff=0)
menu1.add_cascade(label="Varios", menu=menu1_2)
menu1_2.add_command(label="Flores",command=lambda: flores())
menu1_2.add_separator()
menu1_2_1 = Menu(menu1_2, tearoff=0)
menu1_2.add_cascade(label="Frutas", menu=menu1_2_1)
menu1_2_1.add_command(label="FRESA",command=lambda: imprimir("FRESA"))
menu1_2_1.add_command(label="MANZANA",command=lambda: imprimir("MANZANA"))
v0.mainloop()
Suscribirse a:
Entradas (Atom)