jueves, 28 de septiembre de 2017

Programas en Python actualizado hasta poligonos

# -*- coding: utf-8 -*-from Tkinter import *
VentanaPrincipal= Tk()
VentanaPrincipal.title("Ventana Principal")
VentanaPrincipal.config(bg="blue")
VentanaPrincipal.geometry("1300x300")

def ocultar(ventana):ventana.destroy()
def ejecutar(f): VentanaPrincipal.after(200, f)

def ventanas(num):
    Vhija=Toplevel(VentanaPrincipal)
    Vhija.title("FIGURAS")
    Vhija.protocol("WM_DELETE_WINDOW", "onexit")
    Vhija.geometry("500x800")
    if num==1:
        Circulo= Canvas(Vhija, width=300, height=210, bg='blue')
        Circulo.pack(expand=YES, fill=BOTH)
        Circulo.create_oval(10, 10, 400, 400, width=5, fill='White')
        salir= Button(Circulo, text="ocultar ventana", command=lambda: ejecutar(ocultar(Vhija)))
        salir.grid(row=1, column=1)
    elif num==2:
        Rectangulo = Canvas(Vhija, width=300, height=210, bg='white')
        Rectangulo.pack(expand=YES, fill=BOTH)
        Rectangulo.create_rectangle(10, 10, 410, 200, width=5, fill='gold')
        salir= Button(Rectangulo, text="ocultar ventana", command=lambda: ejecutar(ocultar(Vhija)))
        salir.grid(row=1, column=1)
    

lunes, 18 de septiembre de 2017

Múltiples figuras en ventanas hijas

# -*- coding: utf-8 -*-from Tkinter import *
VentanaPrincipal= Tk()
VentanaPrincipal.title("Ventana Principal")
VentanaPrincipal.config(bg="gold")
VentanaPrincipal.geometry("500x500")

def ocultar(ventana):ventana.destroy()
def ejecutar(f): VentanaPrincipal.after(200, f)

def mostrarcirculo():
    Vhija= Toplevel(VentanaPrincipal)
    Vhija.title("CIRCULO")
    Vhija.protocol("WM_DELETE_WINDOW", "onexit")
    Vhija.config(bg="black")
    Vhija.geometry("500x500")
    Circulo= Canvas(Vhija,width=300, height=210, bg='blue')
    Circulo.pack(expand=YES, fill=BOTH)
    Circulo.create_oval(10, 10, 400, 400, width=5, fill='White')
    BotonCirculo1= Button(Circulo, text="ocultar ventana", command=lambda: ejecutar(ocultar(Vhija)))
    BotonCirculo1.grid(row=1, column=3)
    Vhija.deiconify()

def mostrarrectangulo():
    Vhija2= Toplevel(VentanaPrincipal)
    Vhija2.title("RECTANGULO")
    Vhija2.protocol("WM_DELETE_WINDOW", "onexit")
    Vhija2.config(bg="black")
    Vhija2.geometry("500x300")
    Rectangulo= Canvas(Vhija2,width=300, height=210, bg='white')
    Rectangulo.pack(expand=YES, fill=BOTH)
    Rectangulo.create_rectangle(10, 10, 410, 200, width=5, fill='gold')
    BotonRectangulo1= Button(Rectangulo, text="ocultar ventana", command=lambda: ejecutar(ocultar(Vhija2)))
    BotonRectangulo1.grid(row=1, column=3)
    Vhija2.deiconify()

def mostrarlineas():
    Vhija3= Toplevel(VentanaPrincipal)
    Vhija3.title("LINEAS")
    Vhija3.protocol("WM_DELETE_WINDOW", "onexit")
    Vhija3.config(bg="black")
    Vhija3.geometry("300x300")
    linea= Canvas(Vhija3,width=300, height=210, bg='white')
    linea.pack(expand=YES, fill=BOTH)
    linea.create_line(0, 200, 200, 0, width=10, fill='blue')
    linea.create_line(0, 0, 200, 200, width=10, fill='blue')
    Botonlinea= Button(linea, text="ocultar ventana", command=lambda: ejecutar(ocultar(Vhija3)))
    Botonlinea.grid(row=1, column=3)
    Vhija3.deiconify()

def mostrarqueso():
        Vhija4= Toplevel(VentanaPrincipal)
        Vhija4.title("CIRCULO")
        Vhija4.protocol("WM_DELETE_WINDOW", "onexit")
        Vhija4.config(bg="green")
        Vhija4.geometry("500x500")
        queso=Canvas(Vhija4, width=300, height=200, bg='white')
        queso.pack(expand=YES, fill=BOTH)
        queso.create_arc(10, 10, 190, 190, start=270, extent=90, fill='gray90')
        Botonqueso1 = Button(queso, text="ocultar ventana", command=lambda: ejecutar(ocultar(Vhija4)))
        Botonqueso1.grid(row=1, column=3)
        Vhija4.deiconify()


def mostrararco():
    Vhija5= Toplevel(VentanaPrincipal)
    Vhija5.title("CIRCULO")
    Vhija5.protocol("WM_DELETE_WINDOW", "onexit")
    Vhija5.config(bg="green")
    Vhija5.geometry("500x500")
    arco = Canvas(Vhija5, width=300, height=200, bg='white')
    arco.pack(expand=YES, fill=BOTH)
    xy = 40, 40, 190, 190    arco.create_arc(xy, start=0, extent=270, fill='gray60')
    Botonqueso1 = Button(arco, text="ocultar ventana", command=lambda: ejecutar(ocultar(Vhija5)))
    Botonqueso1.grid(row=1, column=3)
    Vhija5.deiconify()

def mostrarpay():
        Vhija6 = Toplevel(VentanaPrincipal)
        Vhija6.title("PAY")
        Vhija6.protocol("WM_DELETE_WINDOW", "onexit")
        Vhija6.config(bg="green")
        Vhija6.geometry("500x500")
        queso = Canvas(Vhija6, width=300, height=200, bg='white')
        queso.pack(expand=YES, fill=BOTH)
        queso.create_arc(60, 60, 200, 200, start=270, extent=90, fill='gray90')
        queso.pack(expand=YES, fill=BOTH)
        xy = 50, 50, 200, 200        queso.create_arc(xy, start=0, extent=270, fill='yellow')
        Botonpay = Button(queso, text="ocultar ventana", command=lambda: ejecutar(ocultar(Vhija6)))
        Botonpay.grid(row=1, column=3)
        Vhija6.deiconify()

boton1= Button(VentanaPrincipal, text="CIRCULO", command=lambda: ejecutar(mostrarcirculo()))
boton1.grid(row=1, column=1)
boton2= Button(VentanaPrincipal, text="RECTANGULO", command=lambda: ejecutar(mostrarrectangulo()))
boton2.grid(row=1, column=2)
boton3= Button(VentanaPrincipal, text="LINEAS", command=lambda: ejecutar(mostrarlineas()))
boton3.grid(row=1, column=3)
boton4= Button(VentanaPrincipal, text="Cerrar Ventana Principal", command=lambda: ejecutar(ocultar(VentanaPrincipal)))
boton4.grid(row=1, column=7)
boton5= Button(VentanaPrincipal, text="QUESO", command=lambda: ejecutar(mostrarqueso()))
boton5.grid(row=1, column=4)
boton6= Button(VentanaPrincipal, text="ARCO", command=lambda: ejecutar(mostrararco()))
boton6.grid(row=1, column=5)
boton7= Button(VentanaPrincipal, text="PAY", command=lambda: ejecutar(mostrarpay()))
boton7.grid(row=1, column=6)
VentanaPrincipal.mainloop()





jueves, 14 de septiembre de 2017

Juego del Gato

from Tkinter import *
import tkMessageBox #para mandar alertas al usuario
import tkSimpleDialog #cajas para pedir informacion
def bloq():
    for i in range(0, 9):
        listabotones[i].config(state="disable")#el estado del boton lo cambia a desabilitado

def iniciar():
    for i in range(0, 9):
        listabotones[i].config(state="normal")#desbloqueamos los botones        
        listabotones[i].config(bg="lightgray")
        listabotones[i].config(text="")#vacia los botones para cuando iniciemos una nueva partida        
        tablero[i] = "N"#limpiar tablero    
    global nomj1, nomj2  # indica a que variables queremos acceder    
    nomj1 = tkSimpleDialog.askstring("Jugador", "Escribe el nombre del jugador 1: ")
           #Pide por medio de una ventana el nombre del jugador    
    nomj2 = tkSimpleDialog.askstring("Jugador", "Escribe el nombre del jugador 2: ")
    turj.set("Turno: " + nomj1)#se le envia a la variable turno de jugador el nombre recibo

def cam(num):
    global turno, nomj1, nomj2 #accedemos a las variables globales    
    if tablero[num] == "N" and turno == 0:
        listabotones[num].config(text="X")# si boton seleccionado esta vacio, pondra una X del 1er jugador        
        listabotones[num].config(bg="white")#cambiar color de fondo del boton        
        tablero[num] = "X"#indica que en ese boton ya hay algo        
        turno = 1#cambia de turno        
        turj.set("Turno: " + nomj2)#turno jugador 2    
    elif tablero[num] == "N" and turno == 1: #si el boton esta vacio y el turno es del segundo jugador hacer...        
        listabotones[num].config(text="O")#asignar  O a ese boton        
        listabotones[num].config(bg="lightblue")
        tablero[num] = "O"#indica que ese boton ya no esta vacio        
        turno = 0#cambio de jugador        
        turj.set("Turno: " + nomj1)#muestra nombre del primer jugador    
    listabotones[num].config(state="disable")#desactiva el boton que se escogio    
    verif()#manda llamar la funcion verificar para saber si gano alguno

def verif(): #medira que jugador gano    
    if (tablero[0] == "X" and tablero[1] == "X" and tablero[2] == "X") or (tablero[3] == "X" and tablero[4] == "X" and tablero[5] == "X") or (
             tablero[6] == "X" and tablero[7] == "X" and tablero[8] == "X"):#formas de ganar horizontalmente del jugador 1        
        bloq()#bloquea botones        
        tkMessageBox.showinfo("Ganaste", "Ganaste jugador: " + nomj1)#muestra quien gano    
    elif (tablero[0] == "X" and tablero[3] == "X" and tablero[6] == "X") or (tablero[1] == "X" and tablero[4] == "X" and tablero[7] == "X") or (
                tablero[2] == "X" and tablero[5] == "X" and tablero[8] == "X"):#formas de ganar verticales del jugador 1        
          bloq()
        tkMessageBox.showinfo("Ganaste", "Ganaste jugador: " + nomj1)
    elif (tablero[0] == "X" and tablero[4] == "X" and tablero[8] == "X") or (tablero[2] == "X" and tablero[4] == "X" and tablero[6] == "X"):
        #forma de ganar diagonal jugador 1        
        bloq()
        tkMessageBox.showinfo("Ganaste", "Ganaste jugador: " + nomj1)
    elif (tablero[0] == "O" and tablero[1] == "O" and tablero[2] == "O") or (tablero[3] == "O" and tablero[4] == "O" and tablero[5] == "O") or (
                tablero[6] == "O" and tablero[7] == "O" and tablero[8] == "O"): #forma de ganar horizontal del jugador 2        
          bloq()
          tkMessageBox.showinfo("Ganaste", "Ganaste jugador: " + nomj2)
    elif (tablero[0] == "O" and tablero[3] == "O" and tablero[6] == "O") or (tablero[1] == "O" and tablero[4] == "O" and tablero[7] == "O") or (
                tablero[2] == "O" and tablero[5] == "O" and tablero[8] == "O"): #forma de ganar vertical del jugador 2        
         bloq()
         tkMessageBox.showinfo("Ganaste", "Ganaste jugador: " + nomj2)
    elif (tablero[0] == "O" and tablero[4] == "O" and tablero[8] == "O") or (tablero[2] == "O" and tablero[4] == "O" and tablero[6] == "O"):
        bloq() #forma de ganar diagonal jugador 2        
        tkMessageBox.showinfo("Ganaste", "Ganaste jugador: " + nomj2)


VP= Tk()
VP.geometry("370x460")
VP.title("Juego del gato")
VP.config(bg="gold")
turno = 0 #variable creada para saber a quien le toca el turno
#creamos variables para almacenar el nombre de los jugadores, pero vacios
nomj1 = ""
nomj2 = ""

listabotones = []#Crea una lista, donde almacenaremos los botones
tablero= []#crea una lista del tablero, para las X y O
turj = StringVar()#Para saber que turno se esta jugando
for i in range(0, 9):
    tablero.append("N") #al tablero le agregara una N a las    
    # posiciones para indicar que no hay nada iniciando el juego

boton0 = Button(VP, width=9, height=3, relief=SOLID, cursor="pencil", command=lambda: cam(0))#crea el boton
listabotones.append(boton0)#agrega boton a la lista
boton0.place(x=50, y=50)# asigna el lugar de posicion del boton, estos van cambiando dependiendo del boton
boton1 = Button(VP, width=9, height=3, relief=SOLID, cursor="pencil", command=lambda: cam(1))
listabotones.append(boton1)
boton1.place(x=150, y=50)
boton2 = Button(VP, width=9, height=3, relief=SOLID, cursor="pencil", command=lambda: cam(2))#manda a la funcion cam su # de boton
listabotones.append(boton2)
boton2.place(x=250, y=50)
boton3 = Button(VP, width=9, height=3, relief=SOLID, cursor="pencil", command=lambda: cam(3))
listabotones.append(boton3)
boton3.place(x=50, y=150)
boton4 = Button(VP, width=9, height=3, relief=SOLID, cursor="pencil", command=lambda: cam(4))
listabotones.append(boton4)
boton4.place(x=150, y=150)
boton5 = Button(VP, width=9, height=3, relief=SOLID, cursor="pencil", command=lambda: cam(5))
listabotones.append(boton5)
boton5.place(x=250, y=150)
boton6 = Button(VP, width=9, height=3, relief=SOLID, cursor="pencil", command=lambda: cam(6))
listabotones.append(boton6)
boton6.place(x=50, y=250)
boton7 = Button(VP, width=9, height=3, relief=SOLID, cursor="pencil", command=lambda: cam(7))
listabotones.append(boton7)
boton7.place(x=150, y=250)
boton8 = Button(VP, width=9, height=3, relief=SOLID, cursor="pencil", command=lambda: cam(8))
listabotones.append(boton8)
boton8.place(x=250, y=250)
turnoetiqueta = Label(VP, textvariable=turj).place(x=140, y=10)#indica de que jugador es el turno actual, llamando a                
#la variable turj creada anteriormente
botoniniciar = Button(VP, bg='blue', fg='white', text='Iniciar juego', cursor="sizing", width=15, height=3,
              command=iniciar).place(x=130, y=360) #boton para iniciar al juego y llama a la funcion iniciar
bloq()#se manda a llamar la funcion bloquear, para bloquear el tablero hasta que el usuario de clic en iniciar

#lineas de divison del gato
linea = Canvas(VP, width=310, height=10) #crea una linea
linea.place(x=30, y=120)#asigna la posicion de la linea
linea.create_line(310, 0, 0, 0, width=25, fill='black')
linea2 = Canvas(VP, width=310, height=10)
linea2.place(x=30, y=220)
linea2.create_line(310, 0, 0, 0, width=25, fill='black')
linea3 = Canvas(VP, width=10, height=310)
linea3.place(x=130, y=25)
linea3.create_line(0, 310, 0, 0, width=25, fill='black')
linea4 = Canvas(VP, width=10, height=310)
linea4.place(x=230, y=25)
linea4.create_line(0, 310, 0, 0, width=25, fill='black')

VP.mainloop()




lunes, 11 de septiembre de 2017

Python: Figuras en ventanas hijas

# -*- coding: utf-8 -*-from Tkinter import *
VentanaPrincipal= Tk()
VentanaPrincipal.title("Ventana Principal")
VentanaPrincipal.config(bg="gold")
VentanaPrincipal.geometry("500x500")

def ocultar(ventana):ventana.destroy()
def ejecutar(f): VentanaPrincipal.after(200, f)

def mostrarcirculo():
    Vhija= Toplevel(VentanaPrincipal)
    Vhija.title("CIRCULO")
    Vhija.protocol("WM_DELETE_WINDOW", "onexit")
    Vhija.config(bg="black")
    Vhija.geometry("500x500")
    Circulo= Canvas(Vhija,width=300, height=210, bg='blue')
    Circulo.pack(expand=YES, fill=BOTH)
    Circulo.create_oval(10, 10, 400, 400, width=5, fill='White')
    BotonCirculo1= Button(Circulo, text="ocultar ventana", command=lambda: ejecutar(ocultar(Vhija)))
    BotonCirculo1.grid(row=1, column=3)
    Vhija.deiconify()

miércoles, 6 de septiembre de 2017

lunes, 4 de septiembre de 2017

Definición de Geometría Fractal

Definición 1:
Un fractal es un ente geométrico el cual en su desarrollo espacial se va reproduciendo a si mismo cada vez a una escala menor. Una característica esencial de los fractales consiste en que si observamos digamos, con una lupa, una parte cualquiera del mismo, ésta reproduce a escala menor la figura total del fractal.

Conclusion de funciones de una DBA

Una base de datos es una coleccion de información accedida y administrada por un DBMS. El DBA es la persona con mas conocimientos sobre bas...