Created
March 25, 2012 21:39
-
-
Save HiroNakamura/2200020 to your computer and use it in GitHub Desktop.
Factorial en Tkinter Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Tkinter import* | |
import sys | |
from math import* | |
def Factorial(n): | |
if n==0: | |
return 1 | |
else: | |
return n*Factorial(n-1) | |
def Obtener_Fact(): | |
print "El factorial del número : ",numero.get()," es ",Factorial(numero.get()) | |
res=Factorial(numero.get()) | |
lblt=Label(Formulario1,text="Resultado: "+str(res)) | |
lblt.grid(row=3,column=0) | |
#------------------------------------------------------------------------------------------ | |
Formulario1=Tk() | |
Formulario1.title('[Factorial]') | |
Formulario1.resizable(width=TRUE,height=TRUE) | |
#------------------------------------------------------------------------------------------ | |
Etiqueta=Label(Formulario1,text="Factorial del número") | |
numero=IntVar() | |
txtnumero=Entry(Formulario1,textvariable=numero,width=15) | |
BotonCalcula=Button(Formulario1,text="Calcular",command=Obtener_Fact,width=10) | |
txtnumero.grid() | |
Etiqueta.grid() | |
BotonCalcula.grid(row=0,column=1) | |
#------------------------------------------------------------------------------------------ | |
Formulario1.mainloop() | |
#------------------------------------------------------------------------------------------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Otro ejemplo de Tkinter
from Tkinter import *
class Application(Frame):
def say_hi(self):
print "hola a todo mundo"
root = Tk()
app = Application(master=root)
root.title('Ejemplo de GUI Tkinter')
app.mainloop()
root.destroy()