Comunidad Underground Hispana  

Retroceder   Comunidad Underground Hispana > Programacion > Python


Respuesta Crear Nuevo Tema
 
LinkBack Herramientas Desplegado
Antiguo 17-sep-2012, 15:18   #1
Recien llegado
 
Fecha de Ingreso: abril-2012
Amigos 0
Mensajes: 9
Gracias: 4
Agradecido 0 veces en 0 mensajes.
Predeterminado Python 2 Tkinter label destroy

Hola a todos. He hecho un convertidor y me funciona todo. Solo necesito hacer unas mejoras. Lo que pasa es que cuando convierto algo, me lo pone la respesta en el label(casi totalmente abajo). Ahora si convierto algo otra vez, me lo convierte de nuevo pero me lo pone la respuesta encima del anterior label y no me lo bora asi que si mi primer respuesta fue mas larga, sobre sale a cada lado de mi ultima respuesta. Eso es mi problema principal pero tengo otro problemita. Quisiera que el boton Calculate que esta totalmente abajo funcione cuando presione Enter y no lo hace. Aqui esta mi codigo.
Código:
#!/usr/bin/python2.7
from Tkinter import *
import ttk
root=Tk()
root.wm_title("Converter")
frame=ttk.Frame(root, width=350, height=0)
frame.grid()
frame.root=root
frame = ttk.Frame(root, pad="3 3 12 12")
Notebook_1=ttk.Notebook(root, height=100)
Frame_1=ttk.Frame(root, height=100)
Frame_1.grid()
Notebook_1.add(Frame_1,text="Distance")
Notebook_1.grid()

a = StringVar()
b = StringVar()
c = float()
d = float()
e = float()
f = float()
# a = Convert From in distance
# b = Convert To in distance
# c = Number of units in distance
# d = Convert From Numerical value in distance
# e = Convert To Numerical value in distance
# f = Answer in distance
# g = Combobox Convert From in distance
# h = Combobox Convert To in distance
# i = Entry in distance
# j = Label in distance
g=ttk.Combobox(Frame_1, width=19, state='readonly', values=('Kilometer','Meter','Centimeter','Millimeter','Micrometer','Nanometer','Mile','Yard','Foot','Inch','Light Year'))
g.grid(column=1, row=1)
g.set("Convert From")
h = ttk.Combobox(Frame_1, width=19, state='readonly', values=('Kilometer','Meter','Centimeter','Millimeter','Micrometer','Nanometer','Mile','Yard','Foot','Inch','Light Year'))
h.grid(column=2, row=1)
h.set("Convert To")
i=ttk.Entry(Frame_1, width=15, textvariable=c)
i.grid(column=3, row=1)
ttk.Label(Frame_1, text="Enter your").grid(column=3, row=2)
ttk.Label(Frame_1, text="number of").grid(column=3, row=3)
ttk.Label(Frame_1, text="units above").grid(column=3, row=4)
g.focus_set()
def calculateD():
    a=g.get()
    b=h.get()
    c=i.get()
    if a == 'Kilometer':
        d = 1000.
    elif a == 'Meter':
        d = 1.
    elif a == 'Centimeter':
        d = 0.01
    elif a == 'Millimeter':
        d = 0.001
    elif a == 'Micrometer':
        d = 0.000001
    elif a == 'Nanometer':
        d = 0.000000001
    elif a == 'Inch':
        d = 0.0254
    elif a == 'Foot':
        d = 0.3048
    elif a == 'Mile':
        d = 1609.344
    elif a == 'Yard':
        d = 0.9144
    elif a == 'Light Year':
        d = 9460730472580800
    else:
        d=0
    if b == 'Kilometer':
        e = 1000.
    elif b == 'Meter':
        e = 1.
    elif b == 'Centimeter':
        e = 0.01
    elif b == 'Millimeter':
        e = 0.001
    elif b == 'Micrometer':
        e = 0.000001
    elif b == 'Nanometer':
        e = 0.000000001
    elif b == 'Inch':
        e = 0.0254
    elif b == 'Foot':
            e = 0.3048
    elif b == 'Mile':
        e = 1609.344
    elif b == 'Yard':
        e = 0.9144
    elif b == 'Light Year':
        e = 9460730472580800
    else:
        e=1
    try:
        c=float(c)
    except:
        c=0.0
        error3=Tk()
        frame.grid()
        error3.wm_title("Error Message")
        ttk.Label(error3, text="You did not enter how many units you have").grid()
    f = d/e*c
    j=ttk.Label(Frame_1, text=f, font=("Helvetica",16)).grid(column=1, row=2, columnspan=2)
ttk.Button(Frame_1, text="Calculate", command=calculateD).grid(column=1, row=3, columnspan=2)
root.mainloop()
  
NelsonRP está desconectado   Responder Citando
Antiguo 18-sep-2012, 12:37   #2
Recien llegado
 
Fecha de Ingreso: julio-2012
Amigos 0
Mensajes: 24
Gracias: 1
Agradecido 1 vez en 1 mensaje.
Predeterminado Respuesta: Python 2 Tkinter label destroy

Tu problema está en esta linea:

Código:
j=ttk.Label(Frame_1, text=f, font=("Helvetica",16)).grid(column=1, row=2, columnspan=2)
  
Con eso estás creando una nueva label, y las estás colocando en cierta parte de tu ventana, pero en ningún lado le dices al programa que debe borrar el label anterior.

No es difícil de solucionar, para ello tienes el comando config:

Código:
#!/usr/bin/python2.7
from Tkinter import *
import ttk
root=Tk()
root.wm_title("Converter")
frame=ttk.Frame(root, width=350, height=0)
frame.grid()
frame.root=root
frame = ttk.Frame(root, pad="3 3 12 12")
Notebook_1=ttk.Notebook(root, height=100)
Frame_1=ttk.Frame(root, height=100)
Frame_1.grid()
Notebook_1.add(Frame_1,text="Distance")
Notebook_1.grid()

a = StringVar()
b = StringVar()
c = float()
d = float()
e = float()
f = float()
# a = Convert From in distance
# b = Convert To in distance
# c = Number of units in distance
# d = Convert From Numerical value in distance
# e = Convert To Numerical value in distance
# f = Answer in distance
# g = Combobox Convert From in distance
# h = Combobox Convert To in distance
# i = Entry in distance
# j = Label in distance
g=ttk.Combobox(Frame_1, width=19, state='readonly', values=('Kilometer','Meter','Centimeter','Millimeter','Micrometer','Nanometer','Mile','Yard','Foot','Inch','Light Year'))
g.grid(column=1, row=1)
g.set("Convert From")
h = ttk.Combobox(Frame_1, width=19, state='readonly', values=('Kilometer','Meter','Centimeter','Millimeter','Micrometer','Nanometer','Mile','Yard','Foot','Inch','Light Year'))
h.grid(column=2, row=1)
h.set("Convert To")
i=ttk.Entry(Frame_1, width=15, textvariable=c)
i.grid(column=3, row=1)

j=ttk.Label(Frame_1, text="", font=("Helvetica",16))
j.grid(column=1, row=2, columnspan=2)

ttk.Label(Frame_1, text="Enter your").grid(column=3, row=2)
ttk.Label(Frame_1, text="number of").grid(column=3, row=3)
ttk.Label(Frame_1, text="units above").grid(column=3, row=4)
g.focus_set()
def calculateD():
    a=g.get()
    b=h.get()
    c=i.get()
    if a == 'Kilometer':
        d = 1000.
    elif a == 'Meter':
        d = 1.
    elif a == 'Centimeter':
        d = 0.01
    elif a == 'Millimeter':
        d = 0.001
    elif a == 'Micrometer':
        d = 0.000001
    elif a == 'Nanometer':
        d = 0.000000001
    elif a == 'Inch':
        d = 0.0254
    elif a == 'Foot':
        d = 0.3048
    elif a == 'Mile':
        d = 1609.344
    elif a == 'Yard':
        d = 0.9144
    elif a == 'Light Year':
        d = 9460730472580800
    else:
        d=0
    if b == 'Kilometer':
        e = 1000.
    elif b == 'Meter':
        e = 1.
    elif b == 'Centimeter':
        e = 0.01
    elif b == 'Millimeter':
        e = 0.001
    elif b == 'Micrometer':
        e = 0.000001
    elif b == 'Nanometer':
        e = 0.000000001
    elif b == 'Inch':
        e = 0.0254
    elif b == 'Foot':
            e = 0.3048
    elif b == 'Mile':
        e = 1609.344
    elif b == 'Yard':
        e = 0.9144
    elif b == 'Light Year':
        e = 9460730472580800
    else:
        e=1
    try:
        c=float(c)
    except:
        c=0.0
        error3=Tk()
        frame.grid()
        error3.wm_title("Error Message")
        ttk.Label(error3, text="You did not enter how many units you have").grid()
    f = d/e*c
    j.config(text=f)
ttk.Button(Frame_1, text="Calculate", command=calculateD).grid(column=1, row=3, columnspan=2)
root.mainloop()
  
Con esto definidos el label "j", lo añadimos al Tk con su respectivo grid, y ahora, la función lo único que hace es editar el texto de dicho label: variable.config(text="nuevo texto"), por lo tanto, no crea una label encima de la anterior, sino que la modifica. También puedes configurar el "font", tamaño de letra, imágenes, y diversas propiedades del Label (si no me equivoco el config también funciona en Buttons y otras cosas).

Ahora, para que funcione al dar la tecla Enter, no sé si la forma que te daré sea la correcta, pero es la que yo utilizaba para hacer mis programas en Tkinter, es la siguiente:

Código:
#!/usr/bin/python2.7
from Tkinter import *
import ttk
root=Tk()
root.wm_title("Converter")
frame=ttk.Frame(root, width=350, height=0)
frame.grid()
frame.root=root
frame = ttk.Frame(root, pad="3 3 12 12")
Notebook_1=ttk.Notebook(root, height=100)
Frame_1=ttk.Frame(root, height=100)
Frame_1.grid()
Notebook_1.add(Frame_1,text="Distance")
Notebook_1.grid()

a = StringVar()
b = StringVar()
c = float()
d = float()
e = float()
f = float()
# a = Convert From in distance
# b = Convert To in distance
# c = Number of units in distance
# d = Convert From Numerical value in distance
# e = Convert To Numerical value in distance
# f = Answer in distance
# g = Combobox Convert From in distance
# h = Combobox Convert To in distance
# i = Entry in distance
# j = Label in distance
g=ttk.Combobox(Frame_1, width=19, state='readonly', values=('Kilometer','Meter','Centimeter','Millimeter','Micrometer','Nanometer','Mile','Yard','Foot','Inch','Light Year'))
g.grid(column=1, row=1)
g.set("Convert From")
h = ttk.Combobox(Frame_1, width=19, state='readonly', values=('Kilometer','Meter','Centimeter','Millimeter','Micrometer','Nanometer','Mile','Yard','Foot','Inch','Light Year'))
h.grid(column=2, row=1)
h.set("Convert To")
i=ttk.Entry(Frame_1, width=15, textvariable=c)
i.grid(column=3, row=1)

j=ttk.Label(Frame_1, text="", font=("Helvetica",16))
j.grid(column=1, row=2, columnspan=2)

ttk.Label(Frame_1, text="Enter your").grid(column=3, row=2)
ttk.Label(Frame_1, text="number of").grid(column=3, row=3)
ttk.Label(Frame_1, text="units above").grid(column=3, row=4)
g.focus_set()
def calculateD(x=False):
    a=g.get()
    b=h.get()
    c=i.get()
    if a == 'Kilometer':
        d = 1000.
    elif a == 'Meter':
        d = 1.
    elif a == 'Centimeter':
        d = 0.01
    elif a == 'Millimeter':
        d = 0.001
    elif a == 'Micrometer':
        d = 0.000001
    elif a == 'Nanometer':
        d = 0.000000001
    elif a == 'Inch':
        d = 0.0254
    elif a == 'Foot':
        d = 0.3048
    elif a == 'Mile':
        d = 1609.344
    elif a == 'Yard':
        d = 0.9144
    elif a == 'Light Year':
        d = 9460730472580800
    else:
        d=0
    if b == 'Kilometer':
        e = 1000.
    elif b == 'Meter':
        e = 1.
    elif b == 'Centimeter':
        e = 0.01
    elif b == 'Millimeter':
        e = 0.001
    elif b == 'Micrometer':
        e = 0.000001
    elif b == 'Nanometer':
        e = 0.000000001
    elif b == 'Inch':
        e = 0.0254
    elif b == 'Foot':
            e = 0.3048
    elif b == 'Mile':
        e = 1609.344
    elif b == 'Yard':
        e = 0.9144
    elif b == 'Light Year':
        e = 9460730472580800
    else:
        e=1
    try:
        c=float(c)
    except:
        c=0.0
        error3=Tk()
        frame.grid()
        error3.wm_title("Error Message")
        ttk.Label(error3, text="You did not enter how many units you have").grid()
    f = d/e*c
    j.config(text=f)
ttk.Button(Frame_1, text="Calculate", command=calculateD).grid(column=1, row=3, columnspan=2)
root.bind("<Return>", calculateD)
root.mainloop()
  
root.bind("<Return>", calculateD) hace que cuando apretes la tecla "Return" (Enter) se active la función o el comando "calculateD", PERO, al usar "bind" se envía automáticamente un parámetro para dicha función, por eso hay que hacer que la función reciba un parámetro. Ahora, el otro problema, es que si la función recibe un parámetro, al hacer click en el botón, este no le entrega ninguna, por lo que debes definir un default para dicho parámetro (x=False). Haciendo eso, te funcionará con la tecla Enter, y además haciendole click al botón.


Espero haber sido claro.

Saludos !
xRodak está desconectado   Responder Citando
El Siguiente Usuario Agradeció a xRodak Por Este Mensaje:
NelsonRP (19-sep-2012)
Antiguo 18-sep-2012, 15:38   #3
Recien llegado
 
Fecha de Ingreso: abril-2012
Amigos 0
Mensajes: 9
Gracias: 4
Agradecido 0 veces en 0 mensajes.
Predeterminado Respuesta: Python 2 Tkinter label destroy

Muchas Gracias, Tus respuestas me funcionaron para lo que te pedi. Otra pregunta, Se puede usar Return para varias diferentes funciones en el mismo programa. Lo que me dijiste funciono. No mas mi programa tiene varias ventanas para Longitud, Masa, Volumen, etc. y solo puedo usar enter para una de ellas.
Ahora sobre las limitaciones que tiene python descritos

[Solo usuarios registrados pueden ver los links. REGISTRARSE]

. Mi programa es una convertidor(calculadora) como ya han visto. Si you calculo 1/12 o 0.01/0.1 la respuesta me sale erronea. Hay alguna resolucion para esto? Para estas preguntas no tiene nada que ver mi codigo pero aqui esta mi programa que hice. Gracias por ayudar, y a ver si tiene solucion esto lo que les dije.
Código:
#!/usr/bin/python2.7
from Tkinter import *
import ttk
root=Tk()
root.wm_title("Converter")
frame=ttk.Frame(root, width=350, height=0)
frame.grid()
frame.root=root
frame = ttk.Frame(root, pad="3 3 12 12")
Notebook_1=ttk.Notebook(root, height=100)
Frame_1=ttk.Frame(root, height=100)
Frame_1.grid()
Frame_2=ttk.Frame(root, height=100)
Frame_2.grid()
Frame_3=ttk.Frame(root, height=100)
Frame_3.grid()
Frame_4=ttk.Frame(root, height=100)
Frame_4.grid()
Frame_5=ttk.Frame(root, height=100)
Frame_5.grid()
Frame_6=ttk.Frame(root, height=100)
Frame_6.grid()
Frame_7=ttk.Frame(root, height=100)
Frame_7.grid()
Notebook_1.add(Frame_1,text="Distance")
Notebook_1.add(Frame_2,text="Weight/Mass")
Notebook_1.add(Frame_3,text="Area")
Notebook_1.add(Frame_4,text="Volume")
Notebook_1.add(Frame_5,text="Temperature")
Notebook_1.add(Frame_6,text="Time")
Notebook_1.add(Frame_7,text="Credits")
Notebook_1.grid()

a = StringVar()
b = StringVar()
c = float()
d = float()
e = float()
f = float()
# a = Convert From in distance
# b = Convert To in distance
# c = Number of units in distance
# d = Convert From Numerical value in distance
# e = Convert To Numerical value in distance
# f = Answer in distance
# g = Combobox Convert From in distance
# h = Combobox Convert To in distance
# i = Entry in distance
# j = Label in distance
g=ttk.Combobox(Frame_1, width=19, state='readonly', values=('Kilometer','Meter','Centimeter','Millimeter','Micrometer','Nanometer','Mile','Yard','Foot','Inch','Light Year'))
g.grid(column=1, row=1)
g.set("Convert From")
h = ttk.Combobox(Frame_1, width=19, state='readonly', values=('Kilometer','Meter','Centimeter','Millimeter','Micrometer','Nanometer','Mile','Yard','Foot','Inch','Light Year'))
h.grid(column=2, row=1)
h.set("Convert To")
i=ttk.Entry(Frame_1, width=15, textvariable=c)
i.grid(column=3, row=1)
j=ttk.Label(Frame_1, text='', font=('Helvetica',16))
j.grid(column=1, row=2, columnspan=2)
ttk.Label(Frame_1, text="Enter your").grid(column=3, row=2)
ttk.Label(Frame_1, text="number of").grid(column=3, row=3)
ttk.Label(Frame_1, text="units above").grid(column=3, row=4)
g.focus_set()
def calculateD(x=False):
    a=g.get()
    b=h.get()
    c=i.get()
    if a == 'Kilometer':
        d = 1000.
    elif a == 'Meter':
        d = 1.
    elif a == 'Centimeter':
        d = 0.01
    elif a == 'Millimeter':
        d = 0.001
    elif a == 'Micrometer':
        d = 0.000001
    elif a == 'Nanometer':
        d = 0.000000001
    elif a == 'Inch':
        d = 0.0254
    elif a == 'Foot':
        d = 0.3048
    elif a == 'Mile':
        d = 1609.344
    elif a == 'Yard':
        d = 0.9144
    elif a == 'Light Year':
        d = 9460730472580800
    else:
        d=0
    if b == 'Kilometer':
        e = 1000.
    elif b == 'Meter':
        e = 1.
    elif b == 'Centimeter':
        e = 0.01
    elif b == 'Millimeter':
        e = 0.001
    elif b == 'Micrometer':
        e = 0.000001
    elif b == 'Nanometer':
        e = 0.000000001
    elif b == 'Inch':
        e = 0.0254
    elif b == 'Foot':
            e = 0.3048
    elif b == 'Mile':
        e = 1609.344
    elif b == 'Yard':
        e = 0.9144
    elif b == 'Light Year':
        e = 9460730472580800
    else:
        e=1
    try:
        c=float(c)
    except:
        c=0.0
        error3=Tk()
        frame.grid()
        error3.wm_title("Error Message")
        ttk.Label(error3, text="You did not enter how many units you have").grid()
    f = d/e*c
    j.config(text=f)
ttk.Button(Frame_1, text="Calculate", command=calculateD).grid(column=1, row=3, columnspan=2)
root.bind('<Return>', calculateD)

k=StringVar()
l=StringVar()
m=float()
n=float()
o=float()
p=float()
# k = Convert From in Weight/Mass
# l = Convert To in Weight/Mass
# m = Number of units in Weight/Mass
# n = Convert From Numerical value in Weight/Mass
# o = Convert To Numerical value in Weight/Mass
# p = Answer in Weight/Mass
# q = Combobox Convert From in Weight/Mass
# r = Combobox Convert To in Weight/Mass
# s = Entry in Weight/Mass
# bh = Label in Weight/Mass
q=ttk.Combobox(Frame_2, width=19, state='readonly', values=('Kilogram','Gram','Milligram','Pound','Ounce','Grain','Newton on Earth'))
q.grid(column=1, row=1)
q.set("Convert From")
r=ttk.Combobox(Frame_2, width=19, state='readonly', values=('Kilogram','Gram','Milligram','Pound','Ounce','Grain','Newton on Earth'))
r.grid(column=2, row=1)
r.set("Convert To")
s=ttk.Entry(Frame_2, width=15, textvariable=m)
s.grid(column=3, row=1)
bh=ttk.Label(Frame_2, text='', font=('Helvetica',16))
bh.grid(column=1, row=2, columnspan=2)
ttk.Label(Frame_2, text="Enter your").grid(column=3, row=2)
ttk.Label(Frame_2, text="number of").grid(column=3, row=3)
ttk.Label(Frame_2, text="units above").grid(column=3, row=4)
q.focus_set()
def calculateW(x=False):
    k=q.get()
    l=r.get()
    m=s.get()
    if k == 'Kilogram':
        o = 0.001
    elif k == 'Gram':
        o = 1.
    elif k == 'Milligram':
        o = 1000
    elif k == 'Pound':
        o = 0.0022046223414059875
    elif k == 'Ounce':
        o = 0.035273399999999996
    elif k == 'Grain':
        o = 15.43
    elif k == 'Newton on Earth':
        o = 9800
    else:
        error4=Tk()
        frame.grid()
        error4.wm_title("Error Message")
        ttk.Label(error4, text="You did enter a unit to be converted from").grid()
    if l == 'Kilogram':
        n = 0.001
    elif l == 'Gram':
        n = 1.
    elif l == 'Milligram':
        n = 1000
    elif l == 'Pound':
        n = 0.0022046223414059875
    elif l == 'Ounce':
        n = 0.035273399999999996
    elif l == 'Grain':
        n = 15.43
    elif l == 'Newton on Earth':
        n = 9800
    else:
        error5=Tk()
        frame.grid()
        error5.wm_title("Error Message")
        ttk.Label(error5, text="You did not enter a unit to be converted to").grid()
    try:
        m=float(m)
    except:
        error6=Tk()
        frame.grid()
        error6.wm_title("Error Message")
        ttk.Label(error6, text="You did not enter how many units you have").grid()
    p = n/o*m
    bh.config(text=p)
ttk.Button(Frame_2, text="Calculate", command=calculateW).grid(column=1, row=3, columnspan=2)

t=StringVar()
u=StringVar()
v=float()
w=float()
x=float()
y=float()
# t = Convert From in Area
# u = Convert To in Area
# v = Number of units in Area
# w = Convert From Numerical value in Area
# x = Convert To Numerical value in Area
# y = Answer in Area
# aa = Combobox Convert From in Area
# ab = Combobox Convert To in Area
# ac = Entry in Area
# ad = Label in Area
aa=ttk.Combobox(Frame_3, width=19, state='readonly', values=('Hectare','Acre','Sqaure Kilometer','Square Meter','Square Millimeter','Sqaure Micrometer','Square Nanometer','Square Mile','Square Yard','Square Foot','Square Inch'))
aa.grid(column=1, row=1)
aa.set("Convert From")
ab=ttk.Combobox(Frame_3, width=19, state='readonly', values=('Hectare','Acre','Sqaure Kilometer','Square Meter','Square Millimeter','Sqaure Micrometer','Square Nanometer','Square Mile','Square Yard','Square Foot','Square Inch'))
ab.grid(column=2, row=1)
ab.set("Convert To")
ac=ttk.Entry(Frame_3, width=15, textvariable=v)
ac.grid(column=3, row=1)
ad=ttk.Label(Frame_3, text='', font=('Helvetica',16))
ad.grid(column=1, row=2, columnspan=2)
ttk.Label(Frame_3, text="Enter your").grid(column=3, row=2)
ttk.Label(Frame_3, text="number of").grid(column=3, row=3)
ttk.Label(Frame_3, text="units above").grid(column=3, row=4)
aa.focus_set()
def calculateA(x=False):
    t=aa.get()
    u=ab.get()
    v=ac.get()
    if t == 'Hectare':
        w = 0.0001
    elif t == 'Acre':
        w =  0.00024710538147
    elif t == 'Sqaure Kilometer':
        w = 0.000001
    elif t == 'Square Meter':
        w = 1.
    elif t == 'Square Millimeter':
        w = 1000000.
    elif t == 'Sqaure Micrometer':
        w = 1000000000000
    elif t == 'Square Nanometer':
        w = 1000000000000000000
    elif t == 'Square Mile':
        w = 0.00000038610215855
    elif t == 'Square Yard':
        w = 1.1959900463
    elif t == 'Square Foot':
        w = 10.763910417 
    elif t == 'Square Inch':
        w = 1550.0031
    else:
        error4=Tk()
        frame.grid()
        error4.wm_title("Error Message")
        ttk.Label(error4, text="You did enter a unit to be converted from").grid()
    if u == 'Hectare':
        x = 0.0001
    elif u == 'Acre':
        x =  0.00024710538147
    elif u == 'Sqaure Kilometer':
        x = 0.000001
    elif u == 'Square Meter':
        x = 1.
    elif u == 'Square Millimeter':
        x = 1000000.
    elif u == 'Sqaure Micrometer':
        x = 1000000000000
    elif u == 'Square Nanometer':
        x = 1000000000000000000
    elif u == 'Square Mile':
        x = 0.00000038610215855
    elif u == 'Square Yard':
        x = 1.1959900463
    elif u == 'Square Foot':
        x = 10.763910417 
    elif u == 'Square Inch':
        x = 1550.0031
    else:
        error5=Tk()
        frame.grid()
        error5.wm_title("Error Message")
        ttk.Label(error5, text="You did not enter a unit to be converted to").grid()
    try:
        v=float(v)
    except:
        error6=Tk()
        frame.grid()
        error6.wm_title("Error Message")
        ttk.Label(error6, text="You did not enter how many units you have").grid()
    y = x/w*v
    ad.config(text=y)
ttk.Button(Frame_3, text="Calculate", command=calculateA).grid(column=1, row=3, columnspan=2)

ae=StringVar()
af=StringVar()
ag=float()
ah=float()
ai=float()
aj=float()
# ae = Convert From in Volume
# af = Convert To in Volume
# ag = Number of units in Volume
# ah = Convert From Numerical value in Volume
# ai = Convert To Numerical value in Volume
# aj = Answer in Volume
# ak = Combobox Convert From in Volume
# al = Combobox Convert To in Volume
# am = Entry in Volume
# an = Label in Volume
ak=ttk.Combobox(Frame_4, width=19, state='readonly', values=('Liter','Kiloliter','Mililiter','Gallon','Quart','Pint','Fluid Ounce','Cubic Milimeter','Cubic Centimeter','Cubic Meter','Cubic Kilometer','Cubic Inch','Cubic Foot','Cubic Yard','Cubic Mile'))
ak.grid(column=1, row=1)
ak.set("Convert From")
al=ttk.Combobox(Frame_4, width=19, state='readonly', values=('Liter','Kiloliter','Mililiter','Gallon','Quart','Pint','Fluid Ounce','Cubic Milimeter','Cubic Centimeter','Cubic Meter','Cubic Kilometer','Cubic Inch','Cubic Foot','Cubic Yard','Cubic Mile'))
al.grid(column=2, row=1)
al.set("Convert To")
am=ttk.Entry(Frame_4, width=15, textvariable=ag)
am.grid(column=3, row=1)
an=ttk.Label(Frame_4, text='', font=('Helvetica',16))
an.grid(column=1, row=2, columnspan=2)
ttk.Label(Frame_4, text="Enter your").grid(column=3, row=2)
ttk.Label(Frame_4, text="number of").grid(column=3, row=3)
ttk.Label(Frame_4, text="units above").grid(column=3, row=4)
ak.focus_set()
def calculateV(x=False):
    ae=ak.get()
    af=al.get()
    ag=am.get()
    if ae == 'Liter':
        ah = 1
    elif ae == 'Kiloliter':
        ah =  0.001
    elif ae == 'Mililiter':
        ah = 1000
    elif ae == 'Gallon':
        ah = 0.2641720523582
    elif ae == 'Quart':
        ah = 1.056688209433
    elif ae == 'Pint':
        ah = 2.113376418865 
    elif ae == 'Cubic Milimeter':
        ah = 1000000
    elif ae == 'Cubic Centimeter':
        ah = 1000
    elif ae == 'Cubic Meter':
        ah = 0.001
    elif ae == 'Cubic Kilometer':
        ah = 0.000000000001
    elif ae == 'Cubic Inch':
        ah = 61.02374409473
    elif ae == 'Cubic Foot':
        ah = 0.03531466672149  
    elif ae == 'Cubic Yard':
        ah = 0.001307950619314 
    elif ae == 'Cubic Mile':
        ah = 0.000000000000239912759
    else:
        error4=Tk()
        frame.grid()
        error4.wm_title("Error Message")
        ttk.Label(error4, text="You did enter a unit to be converted from").grid()
    if af == 'Liter':
        ai = 1
    elif af == 'Kiloliter':
        ai =  0.001
    elif af == 'Mililiter':
        ai = 1000
    elif af == 'Gallon':
        ai = 0.2641720523582
    elif af == 'Quart':
        ai = 1.056688209433
    elif af == 'Pint':
        ai = 2.113376418865 
    elif af == 'Cubic Milimeter':
        ai = 1000000
    elif af == 'Cubic Centimeter':
        ai = 1000
    elif af == 'Cubic Meter':
        ai = 0.001
    elif af == 'Cubic Kilometer':
        ai = 0.000000000001
    elif af == 'Cubic Inch':
        ai = 61.02374409473
    elif af == 'Cubic Foot':
        ai = 0.03531466672149  
    elif af == 'Cubic Yard':
        ai = 0.001307950619314 
    elif af == 'Cubic Mile':
        ai = 0.000000000000239912759
    else:
        error5=Tk()
        frame.grid()
        error5.wm_title("Error Message")
        ttk.Label(error5, text="You did not enter a unit to be converted to").grid()
    try:
        ag=float(ag)
    except:
        error6=Tk()
        frame.grid()
        error6.wm_title("Error Message")
        ttk.Label(error6, text="You did not enter how many units you have").grid()
    aj = ai/ah*ag
    an.config(text=aj)
ttk.Button(Frame_4, text="Calculate", command=calculateV).grid(column=1, row=3, columnspan=2)

ao=StringVar()
ap=StringVar()
aq=float()
ar=float()
at=float()
au=float()
# af = Number of units in Temperature
# ag = Answer in Temperature
# ao = Convert From Value
# ap = Cpnvert To Value
# aq = Combobox Convert From in Temperature
# ar = Combobox Convert To in Temperature
# at = Entry in Temperature
# au = Label in Temperature
aq=ttk.Combobox(Frame_5, width=19, state='readonly', values=('Degree Celsius','Degree Fahrenheit','Kelvin','Degree Rankine','Degree Reamur'))
aq.grid(column=1, row=1)
aq.set("Convert From")
ar=ttk.Combobox(Frame_5, width=19, state='readonly', values=('Degree Celsius','Degree Fahrenheit','Kelvin','Degree Rankine','Degree Reamur'))
ar.grid(column=2, row=1)
ar.set("Convert To")
at=ttk.Entry(Frame_5, width=15, textvariable=aq)
at.grid(column=3, row=1)
au=ttk.Label(Frame_5, text='', font=('Helvetica',16))
au.grid(column=1, row=2, columnspan=2)
ttk.Label(Frame_5, text="Enter your").grid(column=3, row=2)
ttk.Label(Frame_5, text="number of").grid(column=3, row=3)
ttk.Label(Frame_5, text="units above").grid(column=3, row=4)
aq.focus_set()
def calculateT(x=False):
    ao=aq.get()
    ap=ar.get()
    bf=at.get()
    try:
        bf=float(bf)
    except:
        error6=Tk()
        frame.grid()
        error6.wm_title("Error Message")
        ttk.Label(error6, text="You did not enter how many units you have").grid()
    if ao == 'Degree Celsius':
        if ap == 'Degree Celsius':
            bg=bf
        elif ap == 'Degree Fahrenheit':
            bg=bf*9/5+32
        elif ap == 'Kelvin':
            bg=bf+273.15
        elif ap == 'Degree Rankine':
            bg=(bf+273.15)*9/5
        elif ap == 'Degree Reamur':
            bg=bf*4/5
        else:
            error5=Tk()
            frame.grid()
            error5.wm_title("Error Message")
            ttk.Label(error5, text="You did not enter a unit to be converted to").grid()
    elif ao == 'Degree Fahrenheit':
        if ap == 'Degree Celsius':
            bg=(bf-32)*5/9
        elif ap == 'Degree Fahrenheit':
            bg=bf
        elif ap == 'Kelvin':
            bg=(bf+459.67)*5/9
        elif ap == 'Degree Rankine':
            bg=bf+459.67
        elif ap == 'Degree Reamur':
            bg=(bf-32)*7/24+7.5
        else:
            error5=Tk()
            frame.grid()
            error5.wm_title("Error Message")
            ttk.Label(error5, text="You did not enter a unit to be converted to").grid()
    elif ao == 'Kelvin':
        if ap == 'Degree Celsius':
            bg=bf-273.15
        elif ap == 'Degree Fahrenheit':
            bg=bf*9/5-459.67
        elif ap == 'Kelvin':
            bg=bf
        elif ap == 'Degree Rankine':
            bg=bf*9/5
        elif ap == 'Degree Reamur':
            bg=(bf-273.15)*21/40+7.5
        else:
            error5=Tk()
            frame.grid()
            error5.wm_title("Error Message")
            ttk.Label(error5, text="You did not enter a unit to be converted to").grid()
    elif ao == 'Degree Rankine':
        if ap == 'Degree Celsius':
            bg=(bf-491.67)*5/9
        elif ap == 'Degree Fahrenheit':
            bg=bf-459.67
        elif ap == 'Kelvin':
            bf=bf*5/9
        elif ap == 'Degree Rankine':
            bg=bf
        elif ap == 'Degree Reamur':
            bg=(bf-491.67)*7/24+7.5
        else:
            error5=Tk()
            frame.grid()
            error5.wm_title("Error Message")
            ttk.Label(error5, text="You did not enter a unit to be converted to").grid()
    elif ao == 'Degree Reamur':
        if ap == 'Degree Celsius':
            bg=bf*5/4
        elif ap == 'Degree Fahrenheit':
            bg=bf*9/4+32
        elif ap == 'Kelvin':
            bg=bf*5/4+273.15
        elif ap == 'Degree Rankine':
            bg=bf*9/4+491.67
        elif ap == 'Degree Reamur':
            bg=bf
        else:
            error5=Tk()
            frame.grid()
            error5.wm_title("Error Message")
            ttk.Label(error5, text="You did not enter a unit to be converted to").grid()
    else:
        error4=Tk()
        frame.grid()
        error4.wm_title("Error Message")
        ttk.Label(error4, text="You did enter a unit to be converted from").grid()
    au.config(text=bg)
ttk.Button(Frame_5, text="Calculate", command=calculateT).grid(column=1, row=3, columnspan=2)

av=StringVar()
aw=StringVar()
ax=float()
ay=float()
az=float()
ba=float()
# av = Convert From in Time
# aw = Convert To in Time
# ax = Number of units in Time
# ay = Convert From Numerical value in Time
# az = Convert To Numerical value in Time
# ba = Answer in Time
# bb = Combobox Convert From in Time
# bc = Combobox Convert To in Time
# bd = Entry in Time
# be = Label in Time
bb=ttk.Combobox(Frame_6, width=19, state='readonly', values=('Millisecond','Second','Minute','Hour','Day','Week','Month','Year','Decade','Century','Millenium'))
bb.grid(column=1, row=1)
bb.set("Convert From")
bc=ttk.Combobox(Frame_6, width=19, state='readonly', values=('Millisecond','Second','Minute','Hour','Day','Week','Month','Year','Decade','Century','Millenium'))
bc.grid(column=2, row=1)
bc.set("Convert To")
bd=ttk.Entry(Frame_6, width=15, textvariable=ax)
bd.grid(column=3, row=1)
be=ttk.Label(Frame_6, text='', font=('Helvetica',16))
be.grid(column=1, row=2, columnspan=2)
ttk.Label(Frame_6, text="Enter your").grid(column=3, row=2)
ttk.Label(Frame_6, text="number of").grid(column=3, row=3)
ttk.Label(Frame_6, text="units above").grid(column=3, row=4)
bb.focus_set()
def calculateTi(x=False):
    av=bb.get()
    aw=bc.get()
    ax=bd.get()
    if av == 'Millisecond':
        ay = 31536000000
    elif av == 'Second':
        ay =  31536000 
    elif av == 'Minute':
        ay = 525600
    elif av == 'Hour':
        ay =  8760
    elif av == 'Day':
        ay = 365
    elif av == 'Week':
        ay =  52.142857143
    elif av == 'Month':
        ay = 12
    elif av == 'Year':
        ay = 1
    elif av == 'Decade':
        ay = 0.1
    elif av == 'Century':
        ay = 0.01
    elif av == 'Millenium':
        ay = 0.001
    else:
        ay=0
    if aw == 'Millisecond':
        az = 31536000000
    elif aw == 'Second':
        az =  31536000 
    elif aw == 'Minute':
        az = 525600
    elif aw == 'Hour':
        az =  8760
    elif aw == 'Day':
        az = 365
    elif aw == 'Week':
        az =  52.142857143
    elif aw == 'Month':
        az = 12
    elif aw == 'Year':
        az = 1
    elif aw == 'Decade':
        az = 0.1
    elif aw == 'Century':
        az = 0.01
    elif aw == 'Millenium':
        az = 0.001
    else:
        az=0
    try:
        ax=float(ax)
    except:
        ax=0
    ba = az/ay*ax
    be.config(text=ba)
ttk.Button(Frame_6, text="Calculate", command=calculateTi).grid(column=1, row=3, columnspan=2)

ttk.Label(Frame_7, text="Thank you for using Converter").grid(column=1, row=1,padx=20)
ttk.Label(Frame_7, text="Contributed by Nelson Rempel").grid(column=1, row=2)
ttk.Label(Frame_7, text="A servant of").grid(column=1, row=3)
ttk.Label(Frame_7, text="Jesus Christ").grid(column=1, row=4)
ttk.Label(Frame_7, text="On The 8th of May, 2012").grid(column=1, row=5)
ttk.Label(Frame_7, text="For more information").grid(column=3, row=2)
ttk.Label(Frame_7, text="write me an e-mail to").grid(column=3, row=3, padx=20)
ttk.Label(Frame_7, text="

[Solo usuarios registrados pueden ver los links. REGISTRARSE]

").grid(column=3, row=4) root.mainloop()
NelsonRP está desconectado   Responder Citando
Antiguo 19-sep-2012, 06:50   #4
Veterano
 
Avatar de sokoleonardo
 
Fecha de Ingreso: febrero-2011
Ubicación: C:\Argentina\Chaco\Fontana.py
Amigos 7
Mensajes: 655
Gracias: 128
Agradecido 122 veces en 75 mensajes.
Predeterminado Respuesta: Python 2 Tkinter label destroy

Cita:
Iniciado por NelsonRP Ver Mensaje
Muchas Gracias, Tus respuestas me funcionaron para lo que te pedi. Otra pregunta, Se puede usar Return para varias diferentes funciones en el mismo programa. Lo que me dijiste funciono. No mas mi programa tiene varias ventanas para Longitud, Masa, Volumen, etc. y solo puedo usar enter para una de ellas.
Ahora sobre las limitaciones que tiene python descritos

[Solo usuarios registrados pueden ver los links. REGISTRARSE]

. Mi programa es una convertidor(calculadora) como ya han visto. Si you calculo 1/12 o 0.01/0.1 la respuesta me sale erronea. Hay alguna resolucion para esto? Para estas preguntas no tiene nada que ver mi codigo pero aqui esta mi programa que hice. Gracias por ayudar, y a ver si tiene solucion esto lo que les dije.
Código:
#!/usr/bin/python2.7
from Tkinter import *
import ttk
root=Tk()
root.wm_title("Converter")
frame=ttk.Frame(root, width=350, height=0)
frame.grid()
frame.root=root
frame = ttk.Frame(root, pad="3 3 12 12")
Notebook_1=ttk.Notebook(root, height=100)
Frame_1=ttk.Frame(root, height=100)
Frame_1.grid()
Frame_2=ttk.Frame(root, height=100)
Frame_2.grid()
Frame_3=ttk.Frame(root, height=100)
Frame_3.grid()
Frame_4=ttk.Frame(root, height=100)
Frame_4.grid()
Frame_5=ttk.Frame(root, height=100)
Frame_5.grid()
Frame_6=ttk.Frame(root, height=100)
Frame_6.grid()
Frame_7=ttk.Frame(root, height=100)
Frame_7.grid()
Notebook_1.add(Frame_1,text="Distance")
Notebook_1.add(Frame_2,text="Weight/Mass")
Notebook_1.add(Frame_3,text="Area")
Notebook_1.add(Frame_4,text="Volume")
Notebook_1.add(Frame_5,text="Temperature")
Notebook_1.add(Frame_6,text="Time")
Notebook_1.add(Frame_7,text="Credits")
Notebook_1.grid()

a = StringVar()
b = StringVar()
c = float()
d = float()
e = float()
f = float()
# a = Convert From in distance
# b = Convert To in distance
# c = Number of units in distance
# d = Convert From Numerical value in distance
# e = Convert To Numerical value in distance
# f = Answer in distance
# g = Combobox Convert From in distance
# h = Combobox Convert To in distance
# i = Entry in distance
# j = Label in distance
g=ttk.Combobox(Frame_1, width=19, state='readonly', values=('Kilometer','Meter','Centimeter','Millimeter','Micrometer','Nanometer','Mile','Yard','Foot','Inch','Light Year'))
g.grid(column=1, row=1)
g.set("Convert From")
h = ttk.Combobox(Frame_1, width=19, state='readonly', values=('Kilometer','Meter','Centimeter','Millimeter','Micrometer','Nanometer','Mile','Yard','Foot','Inch','Light Year'))
h.grid(column=2, row=1)
h.set("Convert To")
i=ttk.Entry(Frame_1, width=15, textvariable=c)
i.grid(column=3, row=1)
j=ttk.Label(Frame_1, text='', font=('Helvetica',16))
j.grid(column=1, row=2, columnspan=2)
ttk.Label(Frame_1, text="Enter your").grid(column=3, row=2)
ttk.Label(Frame_1, text="number of").grid(column=3, row=3)
ttk.Label(Frame_1, text="units above").grid(column=3, row=4)
g.focus_set()
def calculateD(x=False):
    a=g.get()
    b=h.get()
    c=i.get()
    if a == 'Kilometer':
        d = 1000.
    elif a == 'Meter':
        d = 1.
    elif a == 'Centimeter':
        d = 0.01
    elif a == 'Millimeter':
        d = 0.001
    elif a == 'Micrometer':
        d = 0.000001
    elif a == 'Nanometer':
        d = 0.000000001
    elif a == 'Inch':
        d = 0.0254
    elif a == 'Foot':
        d = 0.3048
    elif a == 'Mile':
        d = 1609.344
    elif a == 'Yard':
        d = 0.9144
    elif a == 'Light Year':
        d = 9460730472580800
    else:
        d=0
    if b == 'Kilometer':
        e = 1000.
    elif b == 'Meter':
        e = 1.
    elif b == 'Centimeter':
        e = 0.01
    elif b == 'Millimeter':
        e = 0.001
    elif b == 'Micrometer':
        e = 0.000001
    elif b == 'Nanometer':
        e = 0.000000001
    elif b == 'Inch':
        e = 0.0254
    elif b == 'Foot':
            e = 0.3048
    elif b == 'Mile':
        e = 1609.344
    elif b == 'Yard':
        e = 0.9144
    elif b == 'Light Year':
        e = 9460730472580800
    else:
        e=1
    try:
        c=float(c)
    except:
        c=0.0
        error3=Tk()
        frame.grid()
        error3.wm_title("Error Message")
        ttk.Label(error3, text="You did not enter how many units you have").grid()
    f = d/e*c
    j.config(text=f)
ttk.Button(Frame_1, text="Calculate", command=calculateD).grid(column=1, row=3, columnspan=2)
root.bind('<Return>', calculateD)

k=StringVar()
l=StringVar()
m=float()
n=float()
o=float()
p=float()
# k = Convert From in Weight/Mass
# l = Convert To in Weight/Mass
# m = Number of units in Weight/Mass
# n = Convert From Numerical value in Weight/Mass
# o = Convert To Numerical value in Weight/Mass
# p = Answer in Weight/Mass
# q = Combobox Convert From in Weight/Mass
# r = Combobox Convert To in Weight/Mass
# s = Entry in Weight/Mass
# bh = Label in Weight/Mass
q=ttk.Combobox(Frame_2, width=19, state='readonly', values=('Kilogram','Gram','Milligram','Pound','Ounce','Grain','Newton on Earth'))
q.grid(column=1, row=1)
q.set("Convert From")
r=ttk.Combobox(Frame_2, width=19, state='readonly', values=('Kilogram','Gram','Milligram','Pound','Ounce','Grain','Newton on Earth'))
r.grid(column=2, row=1)
r.set("Convert To")
s=ttk.Entry(Frame_2, width=15, textvariable=m)
s.grid(column=3, row=1)
bh=ttk.Label(Frame_2, text='', font=('Helvetica',16))
bh.grid(column=1, row=2, columnspan=2)
ttk.Label(Frame_2, text="Enter your").grid(column=3, row=2)
ttk.Label(Frame_2, text="number of").grid(column=3, row=3)
ttk.Label(Frame_2, text="units above").grid(column=3, row=4)
q.focus_set()
def calculateW(x=False):
    k=q.get()
    l=r.get()
    m=s.get()
    if k == 'Kilogram':
        o = 0.001
    elif k == 'Gram':
        o = 1.
    elif k == 'Milligram':
        o = 1000
    elif k == 'Pound':
        o = 0.0022046223414059875
    elif k == 'Ounce':
        o = 0.035273399999999996
    elif k == 'Grain':
        o = 15.43
    elif k == 'Newton on Earth':
        o = 9800
    else:
        error4=Tk()
        frame.grid()
        error4.wm_title("Error Message")
        ttk.Label(error4, text="You did enter a unit to be converted from").grid()
    if l == 'Kilogram':
        n = 0.001
    elif l == 'Gram':
        n = 1.
    elif l == 'Milligram':
        n = 1000
    elif l == 'Pound':
        n = 0.0022046223414059875
    elif l == 'Ounce':
        n = 0.035273399999999996
    elif l == 'Grain':
        n = 15.43
    elif l == 'Newton on Earth':
        n = 9800
    else:
        error5=Tk()
        frame.grid()
        error5.wm_title("Error Message")
        ttk.Label(error5, text="You did not enter a unit to be converted to").grid()
    try:
        m=float(m)
    except:
        error6=Tk()
        frame.grid()
        error6.wm_title("Error Message")
        ttk.Label(error6, text="You did not enter how many units you have").grid()
    p = n/o*m
    bh.config(text=p)
ttk.Button(Frame_2, text="Calculate", command=calculateW).grid(column=1, row=3, columnspan=2)

t=StringVar()
u=StringVar()
v=float()
w=float()
x=float()
y=float()
# t = Convert From in Area
# u = Convert To in Area
# v = Number of units in Area
# w = Convert From Numerical value in Area
# x = Convert To Numerical value in Area
# y = Answer in Area
# aa = Combobox Convert From in Area
# ab = Combobox Convert To in Area
# ac = Entry in Area
# ad = Label in Area
aa=ttk.Combobox(Frame_3, width=19, state='readonly', values=('Hectare','Acre','Sqaure Kilometer','Square Meter','Square Millimeter','Sqaure Micrometer','Square Nanometer','Square Mile','Square Yard','Square Foot','Square Inch'))
aa.grid(column=1, row=1)
aa.set("Convert From")
ab=ttk.Combobox(Frame_3, width=19, state='readonly', values=('Hectare','Acre','Sqaure Kilometer','Square Meter','Square Millimeter','Sqaure Micrometer','Square Nanometer','Square Mile','Square Yard','Square Foot','Square Inch'))
ab.grid(column=2, row=1)
ab.set("Convert To")
ac=ttk.Entry(Frame_3, width=15, textvariable=v)
ac.grid(column=3, row=1)
ad=ttk.Label(Frame_3, text='', font=('Helvetica',16))
ad.grid(column=1, row=2, columnspan=2)
ttk.Label(Frame_3, text="Enter your").grid(column=3, row=2)
ttk.Label(Frame_3, text="number of").grid(column=3, row=3)
ttk.Label(Frame_3, text="units above").grid(column=3, row=4)
aa.focus_set()
def calculateA(x=False):
    t=aa.get()
    u=ab.get()
    v=ac.get()
    if t == 'Hectare':
        w = 0.0001
    elif t == 'Acre':
        w =  0.00024710538147
    elif t == 'Sqaure Kilometer':
        w = 0.000001
    elif t == 'Square Meter':
        w = 1.
    elif t == 'Square Millimeter':
        w = 1000000.
    elif t == 'Sqaure Micrometer':
        w = 1000000000000
    elif t == 'Square Nanometer':
        w = 1000000000000000000
    elif t == 'Square Mile':
        w = 0.00000038610215855
    elif t == 'Square Yard':
        w = 1.1959900463
    elif t == 'Square Foot':
        w = 10.763910417 
    elif t == 'Square Inch':
        w = 1550.0031
    else:
        error4=Tk()
        frame.grid()
        error4.wm_title("Error Message")
        ttk.Label(error4, text="You did enter a unit to be converted from").grid()
    if u == 'Hectare':
        x = 0.0001
    elif u == 'Acre':
        x =  0.00024710538147
    elif u == 'Sqaure Kilometer':
        x = 0.000001
    elif u == 'Square Meter':
        x = 1.
    elif u == 'Square Millimeter':
        x = 1000000.
    elif u == 'Sqaure Micrometer':
        x = 1000000000000
    elif u == 'Square Nanometer':
        x = 1000000000000000000
    elif u == 'Square Mile':
        x = 0.00000038610215855
    elif u == 'Square Yard':
        x = 1.1959900463
    elif u == 'Square Foot':
        x = 10.763910417 
    elif u == 'Square Inch':
        x = 1550.0031
    else:
        error5=Tk()
        frame.grid()
        error5.wm_title("Error Message")
        ttk.Label(error5, text="You did not enter a unit to be converted to").grid()
    try:
        v=float(v)
    except:
        error6=Tk()
        frame.grid()
        error6.wm_title("Error Message")
        ttk.Label(error6, text="You did not enter how many units you have").grid()
    y = x/w*v
    ad.config(text=y)
ttk.Button(Frame_3, text="Calculate", command=calculateA).grid(column=1, row=3, columnspan=2)

ae=StringVar()
af=StringVar()
ag=float()
ah=float()
ai=float()
aj=float()
# ae = Convert From in Volume
# af = Convert To in Volume
# ag = Number of units in Volume
# ah = Convert From Numerical value in Volume
# ai = Convert To Numerical value in Volume
# aj = Answer in Volume
# ak = Combobox Convert From in Volume
# al = Combobox Convert To in Volume
# am = Entry in Volume
# an = Label in Volume
ak=ttk.Combobox(Frame_4, width=19, state='readonly', values=('Liter','Kiloliter','Mililiter','Gallon','Quart','Pint','Fluid Ounce','Cubic Milimeter','Cubic Centimeter','Cubic Meter','Cubic Kilometer','Cubic Inch','Cubic Foot','Cubic Yard','Cubic Mile'))
ak.grid(column=1, row=1)
ak.set("Convert From")
al=ttk.Combobox(Frame_4, width=19, state='readonly', values=('Liter','Kiloliter','Mililiter','Gallon','Quart','Pint','Fluid Ounce','Cubic Milimeter','Cubic Centimeter','Cubic Meter','Cubic Kilometer','Cubic Inch','Cubic Foot','Cubic Yard','Cubic Mile'))
al.grid(column=2, row=1)
al.set("Convert To")
am=ttk.Entry(Frame_4, width=15, textvariable=ag)
am.grid(column=3, row=1)
an=ttk.Label(Frame_4, text='', font=('Helvetica',16))
an.grid(column=1, row=2, columnspan=2)
ttk.Label(Frame_4, text="Enter your").grid(column=3, row=2)
ttk.Label(Frame_4, text="number of").grid(column=3, row=3)
ttk.Label(Frame_4, text="units above").grid(column=3, row=4)
ak.focus_set()
def calculateV(x=False):
    ae=ak.get()
    af=al.get()
    ag=am.get()
    if ae == 'Liter':
        ah = 1
    elif ae == 'Kiloliter':
        ah =  0.001
    elif ae == 'Mililiter':
        ah = 1000
    elif ae == 'Gallon':
        ah = 0.2641720523582
    elif ae == 'Quart':
        ah = 1.056688209433
    elif ae == 'Pint':
        ah = 2.113376418865 
    elif ae == 'Cubic Milimeter':
        ah = 1000000
    elif ae == 'Cubic Centimeter':
        ah = 1000
    elif ae == 'Cubic Meter':
        ah = 0.001
    elif ae == 'Cubic Kilometer':
        ah = 0.000000000001
    elif ae == 'Cubic Inch':
        ah = 61.02374409473
    elif ae == 'Cubic Foot':
        ah = 0.03531466672149  
    elif ae == 'Cubic Yard':
        ah = 0.001307950619314 
    elif ae == 'Cubic Mile':
        ah = 0.000000000000239912759
    else:
        error4=Tk()
        frame.grid()
        error4.wm_title("Error Message")
        ttk.Label(error4, text="You did enter a unit to be converted from").grid()
    if af == 'Liter':
        ai = 1
    elif af == 'Kiloliter':
        ai =  0.001
    elif af == 'Mililiter':
        ai = 1000
    elif af == 'Gallon':
        ai = 0.2641720523582
    elif af == 'Quart':
        ai = 1.056688209433
    elif af == 'Pint':
        ai = 2.113376418865 
    elif af == 'Cubic Milimeter':
        ai = 1000000
    elif af == 'Cubic Centimeter':
        ai = 1000
    elif af == 'Cubic Meter':
        ai = 0.001
    elif af == 'Cubic Kilometer':
        ai = 0.000000000001
    elif af == 'Cubic Inch':
        ai = 61.02374409473
    elif af == 'Cubic Foot':
        ai = 0.03531466672149  
    elif af == 'Cubic Yard':
        ai = 0.001307950619314 
    elif af == 'Cubic Mile':
        ai = 0.000000000000239912759
    else:
        error5=Tk()
        frame.grid()
        error5.wm_title("Error Message")
        ttk.Label(error5, text="You did not enter a unit to be converted to").grid()
    try:
        ag=float(ag)
    except:
        error6=Tk()
        frame.grid()
        error6.wm_title("Error Message")
        ttk.Label(error6, text="You did not enter how many units you have").grid()
    aj = ai/ah*ag
    an.config(text=aj)
ttk.Button(Frame_4, text="Calculate", command=calculateV).grid(column=1, row=3, columnspan=2)

ao=StringVar()
ap=StringVar()
aq=float()
ar=float()
at=float()
au=float()
# af = Number of units in Temperature
# ag = Answer in Temperature
# ao = Convert From Value
# ap = Cpnvert To Value
# aq = Combobox Convert From in Temperature
# ar = Combobox Convert To in Temperature
# at = Entry in Temperature
# au = Label in Temperature
aq=ttk.Combobox(Frame_5, width=19, state='readonly', values=('Degree Celsius','Degree Fahrenheit','Kelvin','Degree Rankine','Degree Reamur'))
aq.grid(column=1, row=1)
aq.set("Convert From")
ar=ttk.Combobox(Frame_5, width=19, state='readonly', values=('Degree Celsius','Degree Fahrenheit','Kelvin','Degree Rankine','Degree Reamur'))
ar.grid(column=2, row=1)
ar.set("Convert To")
at=ttk.Entry(Frame_5, width=15, textvariable=aq)
at.grid(column=3, row=1)
au=ttk.Label(Frame_5, text='', font=('Helvetica',16))
au.grid(column=1, row=2, columnspan=2)
ttk.Label(Frame_5, text="Enter your").grid(column=3, row=2)
ttk.Label(Frame_5, text="number of").grid(column=3, row=3)
ttk.Label(Frame_5, text="units above").grid(column=3, row=4)
aq.focus_set()
def calculateT(x=False):
    ao=aq.get()
    ap=ar.get()
    bf=at.get()
    try:
        bf=float(bf)
    except:
        error6=Tk()
        frame.grid()
        error6.wm_title("Error Message")
        ttk.Label(error6, text="You did not enter how many units you have").grid()
    if ao == 'Degree Celsius':
        if ap == 'Degree Celsius':
            bg=bf
        elif ap == 'Degree Fahrenheit':
            bg=bf*9/5+32
        elif ap == 'Kelvin':
            bg=bf+273.15
        elif ap == 'Degree Rankine':
            bg=(bf+273.15)*9/5
        elif ap == 'Degree Reamur':
            bg=bf*4/5
        else:
            error5=Tk()
            frame.grid()
            error5.wm_title("Error Message")
            ttk.Label(error5, text="You did not enter a unit to be converted to").grid()
    elif ao == 'Degree Fahrenheit':
        if ap == 'Degree Celsius':
            bg=(bf-32)*5/9
        elif ap == 'Degree Fahrenheit':
            bg=bf
        elif ap == 'Kelvin':
            bg=(bf+459.67)*5/9
        elif ap == 'Degree Rankine':
            bg=bf+459.67
        elif ap == 'Degree Reamur':
            bg=(bf-32)*7/24+7.5
        else:
            error5=Tk()
            frame.grid()
            error5.wm_title("Error Message")
            ttk.Label(error5, text="You did not enter a unit to be converted to").grid()
    elif ao == 'Kelvin':
        if ap == 'Degree Celsius':
            bg=bf-273.15
        elif ap == 'Degree Fahrenheit':
            bg=bf*9/5-459.67
        elif ap == 'Kelvin':
            bg=bf
        elif ap == 'Degree Rankine':
            bg=bf*9/5
        elif ap == 'Degree Reamur':
            bg=(bf-273.15)*21/40+7.5
        else:
            error5=Tk()
            frame.grid()
            error5.wm_title("Error Message")
            ttk.Label(error5, text="You did not enter a unit to be converted to").grid()
    elif ao == 'Degree Rankine':
        if ap == 'Degree Celsius':
            bg=(bf-491.67)*5/9
        elif ap == 'Degree Fahrenheit':
            bg=bf-459.67
        elif ap == 'Kelvin':
            bf=bf*5/9
        elif ap == 'Degree Rankine':
            bg=bf
        elif ap == 'Degree Reamur':
            bg=(bf-491.67)*7/24+7.5
        else:
            error5=Tk()
            frame.grid()
            error5.wm_title("Error Message")
            ttk.Label(error5, text="You did not enter a unit to be converted to").grid()
    elif ao == 'Degree Reamur':
        if ap == 'Degree Celsius':
            bg=bf*5/4
        elif ap == 'Degree Fahrenheit':
            bg=bf*9/4+32
        elif ap == 'Kelvin':
            bg=bf*5/4+273.15
        elif ap == 'Degree Rankine':
            bg=bf*9/4+491.67
        elif ap == 'Degree Reamur':
            bg=bf
        else:
            error5=Tk()
            frame.grid()
            error5.wm_title("Error Message")
            ttk.Label(error5, text="You did not enter a unit to be converted to").grid()
    else:
        error4=Tk()
        frame.grid()
        error4.wm_title("Error Message")
        ttk.Label(error4, text="You did enter a unit to be converted from").grid()
    au.config(text=bg)
ttk.Button(Frame_5, text="Calculate", command=calculateT).grid(column=1, row=3, columnspan=2)

av=StringVar()
aw=StringVar()
ax=float()
ay=float()
az=float()
ba=float()
# av = Convert From in Time
# aw = Convert To in Time
# ax = Number of units in Time
# ay = Convert From Numerical value in Time
# az = Convert To Numerical value in Time
# ba = Answer in Time
# bb = Combobox Convert From in Time
# bc = Combobox Convert To in Time
# bd = Entry in Time
# be = Label in Time
bb=ttk.Combobox(Frame_6, width=19, state='readonly', values=('Millisecond','Second','Minute','Hour','Day','Week','Month','Year','Decade','Century','Millenium'))
bb.grid(column=1, row=1)
bb.set("Convert From")
bc=ttk.Combobox(Frame_6, width=19, state='readonly', values=('Millisecond','Second','Minute','Hour','Day','Week','Month','Year','Decade','Century','Millenium'))
bc.grid(column=2, row=1)
bc.set("Convert To")
bd=ttk.Entry(Frame_6, width=15, textvariable=ax)
bd.grid(column=3, row=1)
be=ttk.Label(Frame_6, text='', font=('Helvetica',16))
be.grid(column=1, row=2, columnspan=2)
ttk.Label(Frame_6, text="Enter your").grid(column=3, row=2)
ttk.Label(Frame_6, text="number of").grid(column=3, row=3)
ttk.Label(Frame_6, text="units above").grid(column=3, row=4)
bb.focus_set()
def calculateTi(x=False):
    av=bb.get()
    aw=bc.get()
    ax=bd.get()
    if av == 'Millisecond':
        ay = 31536000000
    elif av == 'Second':
        ay =  31536000 
    elif av == 'Minute':
        ay = 525600
    elif av == 'Hour':
        ay =  8760
    elif av == 'Day':
        ay = 365
    elif av == 'Week':
        ay =  52.142857143
    elif av == 'Month':
        ay = 12
    elif av == 'Year':
        ay = 1
    elif av == 'Decade':
        ay = 0.1
    elif av == 'Century':
        ay = 0.01
    elif av == 'Millenium':
        ay = 0.001
    else:
        ay=0
    if aw == 'Millisecond':
        az = 31536000000
    elif aw == 'Second':
        az =  31536000 
    elif aw == 'Minute':
        az = 525600
    elif aw == 'Hour':
        az =  8760
    elif aw == 'Day':
        az = 365
    elif aw == 'Week':
        az =  52.142857143
    elif aw == 'Month':
        az = 12
    elif aw == 'Year':
        az = 1
    elif aw == 'Decade':
        az = 0.1
    elif aw == 'Century':
        az = 0.01
    elif aw == 'Millenium':
        az = 0.001
    else:
        az=0
    try:
        ax=float(ax)
    except:
        ax=0
    ba = az/ay*ax
    be.config(text=ba)
ttk.Button(Frame_6, text="Calculate", command=calculateTi).grid(column=1, row=3, columnspan=2)

ttk.Label(Frame_7, text="Thank you for using Converter").grid(column=1, row=1,padx=20)
ttk.Label(Frame_7, text="Contributed by Nelson Rempel").grid(column=1, row=2)
ttk.Label(Frame_7, text="A servant of").grid(column=1, row=3)
ttk.Label(Frame_7, text="Jesus Christ").grid(column=1, row=4)
ttk.Label(Frame_7, text="On The 8th of May, 2012").grid(column=1, row=5)
ttk.Label(Frame_7, text="For more information").grid(column=3, row=2)
ttk.Label(Frame_7, text="write me an e-mail to").grid(column=3, row=3, padx=20)
ttk.Label(Frame_7, text="

[Solo usuarios registrados pueden ver los links. REGISTRARSE]

").grid(column=3, row=4) root.mainloop()
NelsonPP, para que el usuario no teclee un 0 en el Entry tenes que hacer muchas lineas de codigo, no te voy a decir que es facil. Tenes que crear una funcion que se ejecute cada vez que el valor del Entry sea modificado.

Mira esta calculadora que no termine, tiene una Entrada de datos Perfecta:
Código:
########################
###      By          ###
### Sokoleonardo(C)  ###
###                  ###
########################



from Tkinter import *;
from tkFont import Font
from math import e, pi
import math




def group_numbers(numbers, replace, slice):
    digits = ""
    digits_reverse = list(numbers)
    digits_reverse.reverse()
    digits_group_reverse = ""
    for index in range(len(digits_reverse)):
        digits_group_reverse += digits_reverse[index] if not ( index in range(slice, len(digits_reverse), slice) ) else replace+digits_reverse[index]
    digits_group = list(digits_group_reverse)
    digits_group.reverse()
    digits = ""
    for digit in digits_group:
        digits += digit
    return digits


def group_numbers_decimal(numbs):
    if type(numbs) in (int, long): numbs = str(numbs)
    sign = ""
    if numbs[0] == "-":
        numbs = numbs[1:]
        sign = "-"
    return sign+group_numbers(numbs, ".", 3)

def ungroup_numbers_decimal(numbs):
    return numbs.replace(".", "")

def ungroup_numbers_binary(binary):
    return binary.replace(" ", "")

def group_numbers_x4(hex_or_binary):
    return group_numbers(hex_or_binary, " ", 4)

def ungroup_numbers_x4(hex_or_binary):
    return hex_or_binary.replace(" ", "")

def group_numbers_octal(octal):
    return group_numbers(octal, " ", 3)

def ungroup_numbers_octal(octal):
    return octal.replace(" ", "")


def binary(integer):
    sign = "-" if integer[0] == "-" else ""
    if sign: integer = integer[1:]
    integer = int(integer)
    rest = []
    while integer > 0:
        rest.append( str(integer % 2) )
        integer /= 2
    rest.reverse()
    bin = ""
    for digit in rest:
        bin += digit
    return sign+bin

def int_binary(bin):
    sign = "-" if bin[0] == "-" else ""
    if sign: bin = bin[1:]
    numbs = list(bin)
    numbs.reverse()
    potences = []
    power = 1
    for bit in [int(i) for i in numbs]:
        if bit != 0:
            potences.append(power)
        power *= 2
    integer = 0
    for n in potences:
        integer += n
    return sign+str(integer)


def sum(x, y):
    return x + y

def difference(x, y):
    return x - y

def product(x, y):
    return x * y

def quotient(x, y):
    return x / y

def exponent(x, y):
    return x ** y

def porcentage(x, y):
    return x * y / 100

def square(x):
    return x * x

def root_square(x):
    return sqrt(x)

def bit_and(x, y):
    return x & y

def bit_or(x, y):
    return x | y

def bit_xor(x, y):
    return x ^ y

def bit_not(n):
    return ~n

def bit_right(x, y):
    return x >> y

def bit_left(x, y):
    return x << y

class About:
    def __init__(self, master):
        self.root = Toplevel(master);
        self.root.title("ITE Calc 666 - About");
        self.root.transient(master);
        self.root.resizable(0, 0);
        self.root.geometry("180x100+%s+%s" % (master.winfo_x(), master.winfo_y()));

        try:
            self.root.iconbitmap("C666.ico")
        except: pass

        self.lbl = Label(self.root, text = "ITE CALC 666  Version-0.1\n Sokoleonardo(C)");
        self.lbl.pack(side = LEFT, fill = X, expand = YES);

class Body:
    def __init__(self):
        self.root = Tk();
        self.root.geometry("420x360");
        self.root.title("ITE calc 666");
        self.root.resizable(False, False);
        self.root["borderwidth"] = 2;
        self.root["relief"] = GROOVE;
        self.root["background"] = "gray70";

        try:
            self.root.iconbitmap("C666.ico")
        except: pass

        self.font_menus = Font(name = "self.font_menus", size = 8, underline = True, weight = "bold")

        self.font_entry_num = Font(size = 8, weight = "bold")

        self.font_buttons = Font(size = 11, weight = "bold")
        self.font_buttons2 = Font(size = 8, weight = "bold")
        self.font_buttons3 = Font(size = 7, weight = "bold")

        self.base_menus = LabelFrame(self.root, background = "gray50", relief = FLAT)
        self.base_menus.pack(side = TOP, fill = X)
        
        self.button_menu_edit = Menubutton(self.base_menus, text = "Edit", font = self.font_menus, background = "gray65", activebackground = "gray75", foreground = "black", activeforeground = "black")
        self.button_menu_edit.pack(side = LEFT, padx = 1)
        self.menu_edit = Menu(self.button_menu_edit, tearoff = False, background = "gray65", activebackground = "gray85", foreground = "black", activeforeground = "black")
        self.menu_edit.add_command(label = "Copy", accelerator = "Ctrl+C", command = self.clipboard_copy)
        self.menu_edit.add_separator()
        self.menu_edit.add_command(label = "Clear", accelerator = "SUPR", command = self.clear_numerals)
        self.button_menu_edit["menu"] = self.menu_edit

        self.root.bind("<Control-c>", self.clipboard_copy)

        self.button_menu_numerals = Menubutton(self.base_menus, text = "Numerals", font = self.font_menus, background = "gray65", activebackground = "gray75", foreground = "black", activeforeground = "black")
        self.button_menu_numerals.pack(side = LEFT, padx = 1)
        self.menu_numerals = Menu(self.button_menu_numerals, tearoff = False, background = "gray65", activebackground = "gray85", foreground = "black", activeforeground = "black")
        self.bool_numerals = IntVar(value = 1)
        self.menu_numerals.add_radiobutton(label = "Decimal", variable = self.bool_numerals, selectcolor = "red4", value = 1, command = self.change_type_numerals)
        self.menu_numerals.add_radiobutton(label = "Binary", variable = self.bool_numerals, selectcolor = "red4", value = 2, command = self.change_type_numerals)
        self.menu_numerals.add_radiobutton(label = "Octal", variable = self.bool_numerals, selectcolor = "red4", value = 3, command = self.change_type_numerals)
        self.menu_numerals.add_radiobutton(label = "Hexadecimal", variable = self.bool_numerals, selectcolor = "red4", value = 4, command = self.change_type_numerals)
        self.bool_view_group = IntVar(value = 1)
        self.menu_numerals.add_separator()
        self.menu_numerals.add_checkbutton(label = "To group numbers", selectcolor = "red4", variable = self.bool_view_group, accelerator = "Ctrl+G", command = self.ajust_group_ungroup)
        self.button_menu_numerals["menu"] = self.menu_numerals
        
        self.button_menu_help = Menubutton(self.base_menus, text = "Help", font = self.font_menus, background = "gray65", activebackground = "gray75", foreground = "black", activeforeground = "black")
        self.button_menu_help.pack(side = LEFT, padx = 1)
        self.menu_help = Menu(self.button_menu_help, tearoff = False, background = "gray65", activebackground = "gray85", foreground = "black", activeforeground = "black")
        self.bool_help = IntVar(value = 1)
        self.menu_help.add_command(label = "Help", accelerator = "F12")
        self.menu_help.add_command(label = "About", command = self.about)
        self.button_menu_help["menu"] = self.menu_help
        
        #################################

        self.base_radiobutton_numerals = LabelFrame(self.root, background = "gray50", relief = GROOVE)
        self.base_radiobutton_numerals.pack(side = TOP, padx = 5, pady = 5, fill = X)

        self.radiobutton_decimal = Radiobutton(self.base_radiobutton_numerals, variable = self.bool_numerals, value = 1, text = "Decimal", selectcolor = "gray85", background = "gray50", activebackground = "gray50", foreground = "blue4", activeforeground = "blue4", command = self.change_type_numerals)
        self.radiobutton_decimal.pack(side = LEFT, expand = YES)
        self.radiobutton_binary = Radiobutton(self.base_radiobutton_numerals, variable = self.bool_numerals, value = 2, text = "Binary", selectcolor = "gray85", background = "gray50", activebackground = "gray50", foreground = "blue4", activeforeground = "blue4", command = self.change_type_numerals)
        self.radiobutton_binary.pack(side = LEFT, expand = YES)
        self.radiobutton_octal = Radiobutton(self.base_radiobutton_numerals, variable = self.bool_numerals, value = 3, text = "Octal", selectcolor = "gray85", background = "gray50", activebackground = "gray50", foreground = "blue4", activeforeground = "blue4", command = self.change_type_numerals)
        self.radiobutton_octal.pack(side = LEFT, expand = YES)
        self.radiobutton_hexadecimal = Radiobutton(self.base_radiobutton_numerals, variable = self.bool_numerals, value = 4, text = "Hexadecimal", selectcolor = "gray85", background = "gray50", activebackground = "gray50", foreground = "blue4", activeforeground = "blue4", command = self.change_type_numerals)
        self.radiobutton_hexadecimal.pack(side = LEFT, expand = YES)
        
        self.entry_numerals = Entry(self.root, foreground = "blue", relief = RIDGE, background = "gray90", font = self.font_entry_num, justify = "right")
        self.entry_numerals.pack(side = TOP, padx = 5, fill = X)
        self.entry_numerals.insert(0, "0,0")
        self.entry_numerals["state"] = "readonly"
        self.entry_numerals["readonlybackground"] = self.entry_numerals["background"]
        self.entry_numerals.insert(0, "0,0")
        self.entry_numerals.bind("<ButtonRelease-3>", self.despl_menu_clipboard)
        
        self.position_insert_numb = "integer"
        self.expression_avalaible = "0123456789"
        self.max_len_decimals = 12
        self.max_len_integers = 32
        self.max_len_binary = 56
        self.max_len_octal = 22
        self.max_len_hexadecimal = 24

        for num_key in range(0, 10):
            self.root.bind(str(num_key), self.appropriate_keypress)
        for char_key in "abcdef,":
            self.root.bind(char_key, self.appropriate_keypress)
        self.root.bind("<BackSpace>", self.delete_one_char)
        self.root.bind("<Delete>", self.clear_numerals)

        self.base1_buttons = LabelFrame(self.root, background = "gray60", relief = GROOVE)
        self.base1_buttons.place(x = 5, y = 92, width = 143, height = 47)
        self.button_add_7 = Button(self.base1_buttons, borderwidth = 10, font = self.font_buttons, text = "7", disabledforeground = "gray10", background = "gray40", activebackground = "gray55", foreground = "#7AFFD5", activeforeground = "#7AFFD5", command = lambda: (self.insert_text("7")))
        self.button_add_7.place(x = 1, y = 1, width = 42, height = 40)
        self.button_add_8 = Button(self.base1_buttons, borderwidth = 10, font = self.font_buttons, text = "8", disabledforeground = "gray10", background = "gray40", activebackground = "gray55", foreground = "#7AFFD5", activeforeground = "#7AFFD5", command = lambda: (self.insert_text("8")))
        self.button_add_8.place(x = 48, y = 1, width = 42, height = 40)
        self.button_add_9 = Button(self.base1_buttons, borderwidth = 10, font = self.font_buttons, text = "9", disabledforeground = "gray10", background = "gray40", activebackground = "gray55", foreground = "#7AFFD5", activeforeground = "#7AFFD5", command = lambda: (self.insert_text("9")))
        self.button_add_9.place(x = 95, y = 1, width = 42, height = 40)
        
        self.base2_buttons = LabelFrame(self.root, background = "gray60", relief = GROOVE)
        self.base2_buttons.place(x = 5, y = 144, width = 143, height = 47)
        self.button_add_4 = Button(self.base2_buttons, borderwidth = 10, font = self.font_buttons, text = "4", disabledforeground = "gray10", background = "gray40", activebackground = "gray55", foreground = "#7AFFD5", activeforeground = "#7AFFD5", command = lambda: (self.insert_text("4")))
        self.button_add_4.place(x = 1, y = 1, width = 42, height = 40)
        self.button_add_5 = Button(self.base2_buttons, borderwidth = 10, font = self.font_buttons, text = "5", disabledforeground = "gray10", background = "gray40", activebackground = "gray55", foreground = "#7AFFD5", activeforeground = "#7AFFD5", command = lambda: (self.insert_text("5")))
        self.button_add_5.place(x = 48, y = 1, width = 42, height = 40)
        self.button_add_6 = Button(self.base2_buttons, borderwidth = 10, font = self.font_buttons, text = "6", disabledforeground = "gray10", background = "gray40", activebackground = "gray55", foreground = "#7AFFD5", activeforeground = "#7AFFD5", command = lambda: (self.insert_text("6")))
        self.button_add_6.place(x = 95, y = 1, width = 42, height = 40)

        self.base3_buttons = LabelFrame(self.root, background = "gray60", relief = GROOVE)
        self.base3_buttons.place(x = 5, y = 196, width = 143, height = 47)
        self.button_add_1 = Button(self.base3_buttons, borderwidth = 10, font = self.font_buttons, text = "1", disabledforeground = "gray10", background = "gray40", activebackground = "gray55", foreground = "#7AFFD5", activeforeground = "#7AFFD5", command = lambda: (self.insert_text("1")))
        self.button_add_1.place(x = 1, y = 1, width = 42, height = 40)
        self.button_add_2 = Button(self.base3_buttons, borderwidth = 10, font = self.font_buttons, text = "2", disabledforeground = "gray10", background = "gray40", activebackground = "gray55", foreground = "#7AFFD5", activeforeground = "#7AFFD5", command = lambda: (self.insert_text("2")))
        self.button_add_2.place(x = 48, y = 1, width = 42, height = 40)
        self.button_add_3 = Button(self.base3_buttons, borderwidth = 10, font = self.font_buttons, text = "3", disabledforeground = "gray10", background = "gray40", activebackground = "gray55", foreground = "#7AFFD5", activeforeground = "#7AFFD5", command = lambda: (self.insert_text("3")))
        self.button_add_3.place(x = 95, y = 1, width = 42, height = 40)


        self.base4_buttons = LabelFrame(self.root, background = "gray60", relief = GROOVE)
        self.base4_buttons.place(x = 5, y = 248, width = 143, height = 47)
        self.button_add_0 = Button(self.base4_buttons, borderwidth = 10, font = self.font_buttons, text = "0", disabledforeground = "gray10", background = "gray40", activebackground = "gray55", foreground = "#7AFFD5", activeforeground = "#7AFFD5", command = lambda: (self.insert_text("0")))
        self.button_add_0.place(x = 1, y = 1, width = 42, height = 40)
        self.button_change_sign = Button(self.base4_buttons, borderwidth = 10, font = self.font_buttons, text = "+/-", disabledforeground = "gray10", background = "gray40", activebackground = "gray55", foreground = "#7AFFD5", activeforeground = "#7AFFD5", command = self.change_sign)
        self.button_change_sign.place(x = 48, y = 1, width = 42, height = 40)
        self.button_comma = Button(self.base4_buttons, borderwidth = 10, font = self.font_buttons, text = ",", disabledforeground = "gray10", background = "gray40", activebackground = "gray55", foreground = "#7AFFD5", activeforeground = "#7AFFD5", command = self.set_cursor_decimal)
        self.button_comma.place(x = 95, y = 1, width = 42, height = 40)

        self.base5_buttons = LabelFrame(self.root, background = "gray60", relief = GROOVE)
        self.base5_buttons.place(x = 160, y = 92, width = 143, height = 99)
        self.button_add_a = Button(self.base5_buttons, borderwidth = 10, font = self.font_buttons, state = DISABLED,text = "A", disabledforeground = "gray10", background = "gray40", activebackground = "gray55", foreground = "green3", activeforeground = "green4", command = lambda:(self.insert_text("a")))
        self.button_add_a.place(x = 1, y = 1, width = 42, height = 40)
        self.button_add_b = Button(self.base5_buttons, borderwidth = 10, font = self.font_buttons, state = DISABLED, text = "B", disabledforeground = "gray10", background = "gray40", activebackground = "gray55", foreground = "green3", activeforeground = "green4", command = lambda:(self.insert_text("b")))
        self.button_add_b.place(x = 48, y = 1, width = 42, height = 40)
        self.button_add_c = Button(self.base5_buttons, borderwidth = 10, font = self.font_buttons, state = DISABLED, text = "C", disabledforeground = "gray10", background = "gray40", activebackground = "gray55", foreground = "green3", activeforeground = "green4", command = lambda:(self.insert_text("c")))
        self.button_add_c.place(x = 95, y = 1, width = 42, height = 40)
        self.button_add_d = Button(self.base5_buttons, borderwidth = 10, font = self.font_buttons, state = DISABLED, text = "D", disabledforeground = "gray10", background = "gray40", activebackground = "gray55", foreground = "green3", activeforeground = "green4", command = lambda:(self.insert_text("d")))
        self.button_add_d.place(x = 1, y = 53, width = 42, height = 40)
        self.button_add_e = Button(self.base5_buttons, borderwidth = 10, font = self.font_buttons, state = DISABLED, text = "E", disabledforeground = "gray10", background = "gray40", activebackground = "gray55", foreground = "green3", activeforeground = "green4", command = lambda:(self.insert_text("e")))
        self.button_add_e.place(x = 48, y = 53, width = 42, height = 40)
        self.button_add_f = Button(self.base5_buttons, borderwidth = 10, font = self.font_buttons, state = DISABLED, text = "F", disabledforeground = "gray10", background = "gray40", activebackground = "gray55", foreground = "green3", activeforeground = "green4", command = lambda:(self.insert_text("f")))
        self.button_add_f.place(x = 95, y = 53, width = 42, height = 40)

        self.base6_buttons = LabelFrame(self.root, background = "gray60", relief = GROOVE)
        self.base6_buttons.place(x = 160, y = 196, width = 143, height = 99)
        self.button_sum = Button(self.base6_buttons, borderwidth = 10, font = self.font_buttons, text = "+", background = "gray40", activebackground = "gray55", foreground = "#E1FF21", activeforeground = "#E1FF21")
        self.button_sum.place(x = 1, y = 1, width = 42, height = 40)
        self.button_subtraction = Button(self.base6_buttons, borderwidth = 10, font = self.font_buttons, text = "-", background = "gray40", activebackground = "gray55", foreground = "#E1FF21", activeforeground = "#E1FF21")
        self.button_subtraction.place(x = 48, y = 1, width = 42, height = 40)
        self.button_multiplication = Button(self.base6_buttons, borderwidth = 10, font = self.font_buttons, text = "*", background = "gray40", activebackground = "gray55", foreground = "#E1FF21", activeforeground = "#E1FF21")
        self.button_multiplication.place(x = 95, y = 1, width = 42, height = 40)
        self.button_porcent = Button(self.base6_buttons, borderwidth = 10, font = self.font_buttons3, text = "por\n%", background = "gray40", activebackground = "gray55", foreground = "#E1FF21", activeforeground = "#E1FF21")
        self.button_porcent.place(x = 1, y = 53, width = 42, height = 40)
        self.button_division = Button(self.base6_buttons, borderwidth = 10, font = self.font_buttons2, text = "/", background = "gray40", activebackground = "gray55", foreground = "#E1FF21", activeforeground = "#E1FF21")
        self.button_division.place(x = 48, y = 53, width = 42, height = 40)
        self.button_pow = Button(self.base6_buttons, borderwidth = 10, font = self.font_buttons, text = "**", background = "gray40", activebackground = "gray55", foreground = "#E1FF21", activeforeground = "#E1FF21")
        self.button_pow.place(x = 95, y = 53, width = 42, height = 40)

        self.base7_buttons = LabelFrame(self.root, background = "gray60", relief = GROOVE)
        self.base7_buttons.place(x = 315, y = 92, width = 96, height = 47)
        self.button_add_value_e = Button(self.base7_buttons, borderwidth = 10, font = self.font_buttons, text = "e", disabledforeground = "gray10", background = "gray40", activebackground = "gray55", foreground = "white", activeforeground = "white", command = self.insert_e)
        self.button_add_value_e.place(x = 1, y = 1, width = 42, height = 40)
        self.button_add_value_pi = Button(self.base7_buttons, borderwidth = 10, font = self.font_buttons, text = "pi", disabledforeground = "gray10", background = "gray40", activebackground = "gray55", foreground = "white", activeforeground = "white", command = self.insert_pi)
        self.button_add_value_pi.place(x = 48, y = 1, width = 42, height = 40)

        self.base8_buttons = LabelFrame(self.root, background = "gray60", relief = GROOVE)
        self.base8_buttons.place(x = 315, y = 144, width = 96, height = 151)
        self.button_bit_left = Button(self.base8_buttons, borderwidth = 10, font = self.font_buttons, text = "<<", background = "gray40", activebackground = "gray55", foreground = "#149BFF", activeforeground = "#2652FF")
        self.button_bit_left.place(x = 1, y = 1, width = 42, height = 40)
        self.button_bit_right = Button(self.base8_buttons, borderwidth = 10, font = self.font_buttons, text = ">>", background = "gray40", activebackground = "gray55", foreground = "#149BFF", activeforeground = "#2652FF")
        self.button_bit_right.place(x = 48, y = 1, width = 42, height = 40)
        self.button_bit_or = Button(self.base8_buttons, borderwidth = 10, font = self.font_buttons, text = "or", background = "gray40", activebackground = "gray55", foreground = "#149BFF", activeforeground = "#2652FF")
        self.button_bit_or.place(x = 1, y = 53, width = 42, height = 40)
        self.button_bit_xor = Button(self.base8_buttons, borderwidth = 10, font = self.font_buttons, text = "xor", background = "gray40", activebackground = "gray55", foreground = "#149BFF", activeforeground = "#2652FF")
        self.button_bit_xor.place(x = 48, y = 53, width = 42, height = 40)
        self.button_bit_and = Button(self.base8_buttons, borderwidth = 10, font = self.font_buttons, text = "&", background = "gray40", activebackground = "gray55", foreground = "#149BFF", activeforeground = "#2652FF")
        self.button_bit_and.place(x = 1, y = 105, width = 42, height = 40)
        self.button_bit_not = Button(self.base8_buttons, borderwidth = 10, font = self.font_buttons, text = "not", background = "gray40", activebackground = "gray55", foreground = "#149BFF", activeforeground = "#2652FF", command = self.to_bit_not)
        self.button_bit_not.place(x = 48, y = 105, width = 42, height = 40)

        self.base9_buttons = LabelFrame(self.root, background = "gray60", relief = GROOVE)
        self.base9_buttons.place(x = 5, y = 300, width = 49, height = 47)
        self.button_result = Button(self.base9_buttons, borderwidth = 10, font = self.font_buttons, text = "=", background = "gray40", activebackground = "gray55", foreground = "#7AFFD5", activeforeground = "#7AFFD5")
        self.button_result.place(x = 1, y = 1, width = 42, height = 40)

        self.base10_buttons = LabelFrame(self.root, background = "gray60", relief = GROOVE)
        self.base10_buttons.place(x = 160, y = 300, width = 143, height = 47)
        self.button_module = Button(self.base10_buttons, borderwidth = 10, font = self.font_buttons3, text = "mod\n%", background = "gray40", activebackground = "gray55", foreground = "#E1FF21", activeforeground = "#E1FF21")
        self.button_module.place(x = 1, y = 1, width = 42, height = 40)
        self.button_n2pow = Button(self.base10_buttons, borderwidth = 10, font = self.font_buttons2, text = "N^2", background = "gray40", activebackground = "gray55", foreground = "pink", activeforeground = "pink", command = self.to_square)
        self.button_n2pow.place(x = 48, y = 1, width = 42, height = 40)
        self.button_sqrt = Button(self.base10_buttons, borderwidth = 10, font = self.font_buttons2, text = "sqrt", disabledforeground = "gray10", background = "gray40", activebackground = "gray55", foreground = "pink", activeforeground = "pink")
        self.button_sqrt.place(x = 95, y = 1, width = 42, height = 40)

        self.base11_buttons = LabelFrame(self.root, background = "gray60", relief = GROOVE)
        self.base11_buttons.place(x = 315, y = 300, width = 96, height = 47)
        self.button_back = Button(self.base11_buttons, borderwidth = 10, font = self.font_buttons2, text = "Retr", background = "gray40", activebackground = "gray55", foreground = "red3", activeforeground = "red", command = self.delete_one_char)
        self.button_back.place(x = 1, y = 1, width = 42, height = 40)
        self.button_delete = Button(self.base11_buttons, borderwidth = 10, font = self.font_buttons2, text = "Del", background = "gray40", activebackground = "gray55", foreground = "red3", activeforeground = "red", command = self.clear_numerals)
        self.button_delete.place(x = 48, y = 1, width = 42, height = 40)

    def about(self):
        r = About(self.root);

    def despl_menu_clipboard(self, *e):
        x_despl = e[0].x_root
        y_despl = e[0].y_root
        self.menu_edit.post(x_despl, y_despl)

    def clipboard_copy(self, *e):
        text = self.entry_numerals.get()
        self.entry_numerals.clipboard_clear()
        self.entry_numerals.clipboard_append(text)

    def appropriate_keypress(self, *e):
        key_controls = e[0].keysym
        key = e[0].char
        if key in self.expression_avalaible:
            self.insert_text(key)
        elif key == ",":
            self.set_cursor_decimal()
        elif key in "1234567890abcdef":
            self.root.bell()

    def set_cursor_decimal(self):
        self.position_insert_numb = "decimal"

    def insert_pi(self):
        self.entry_numerals["state"] = NORMAL
        self.entry_numerals.delete(0, END)
        self.entry_numerals.insert(0, str(pi).replace(".", ","))
        self.entry_numerals["state"] = "readonly"

    def select_first_number(self):
        numeral = self.bool_numerals.get()
        if numeral == 1:
            self.first_number = ungroup_numbers_decimal(self.entry_numerals.get())
        elif numeral == 2:
            pass
        
    def insert_e(self):
        self.entry_numerals["state"] = NORMAL
        self.entry_numerals.delete(0, END)
        self.entry_numerals.insert(0, str(e).replace(".", ","))
        self.entry_numerals["state"] = "readonly"

    def change_sign(self):
        self.entry_numerals["state"] = NORMAL
        text_actual = self.entry_numerals.get()
        self.entry_numerals.delete(0, END)
        if text_actual[0] == "-":
            text_actual = text_actual[1:]
        else:
            text_actual = "-" + text_actual
        self.entry_numerals.insert(0, text_actual)
        self.entry_numerals["state"] = "readonly"
        

    def clear_numerals(self, *e):
        numeral = self.bool_numerals.get()
        self.entry_numerals["state"] = NORMAL
        self.entry_numerals.delete(0, END)
        default_text = "0,0" if numeral == 1 else "0"
        self.entry_numerals.insert(0, default_text)
        self.position_insert_numb = "integer"
        self.entry_numerals["state"] = "readonly"

    def delete_one_char(self, *e):
        actual_text = self.entry_numerals.get()
        numeral = self.bool_numerals.get()
        bool_group = self.bool_view_group.get()
        self.entry_numerals["state"] = NORMAL
        self.entry_numerals.delete(0, END)
        if numeral == 1:
            #decimal
            integer, decimal = actual_text.split(",")
            if bool_group:
                integer = ungroup_numbers_decimal(integer)
            if decimal != "0":
                decimal = decimal[:-1]
                if decimal == "":
                    decimal = "0"
                    self.position_insert_numb = "integer"
            else:
                integer = integer[:-1]
                if integer == "":
                    integer = "0"
            if bool_group:
                text_nw = group_numbers_decimal(integer) + "," + decimal
            else:    
                text_nw = integer + "," + decimal
        elif numeral == 3:
            #octal
            text_nw = ungroup_numbers_octal(actual_text)[:-1]
            if not text_nw:
                text_nw = "0"
            if bool_group:
                text_nw = group_numbers_octal(text_nw)
        else:
            #binary and hexadecimal
            text_nw = ungroup_numbers_x4(actual_text)[:-1]
            if text_nw == "":
                text_nw = "0"
            if bool_group:
                text_nw = group_numbers_x4(text_nw)
        self.entry_numerals.insert(0, text_nw.upper())
        self.entry_numerals["state"] = "readonly"

    def ajust_group_ungroup(self):
        actual_text = self.entry_numerals.get()
        bool_group = self.bool_view_group.get()
        self.entry_numerals["state"] = NORMAL
        self.entry_numerals.delete(0, END)
        numeral = self.bool_numerals.get()
        if numeral == 1:
            integer, decimal = actual_text.split(",")
            if bool_group:
                text_nw = group_numbers_decimal(ungroup_numbers_decimal(integer))+","+decimal
            else:
                text_nw = ungroup_numbers_decimal(integer)+","+decimal
        elif numeral in (2, 4):
            if bool_group:
                text_nw = group_numbers_x4(actual_text)
            else:
                text_nw = ungroup_numbers_x4(actual_text)
        else:
            text_nw = actual_text
        self.entry_numerals.insert(0, text_nw)
        self.entry_numerals["state"] = "readonly"
            
    def insert_text(self, text):
        actual_text = self.entry_numerals.get()
        bool_group = self.bool_view_group.get()
        self.entry_numerals["state"] = NORMAL
        def delete():
            self.entry_numerals.delete(0, END)
        def insert(mytext):
            self.entry_numerals.insert(0, mytext.upper())
        numeral = self.bool_numerals.get()
        if numeral == 1:
            #decimal
            integer, decimal = actual_text.split(",")
            if self.position_insert_numb == "integer":
                integer = ungroup_numbers_decimal(integer)
                if len(integer) < self.max_len_integers:
                    delete()
                    integer = (integer if integer != "0" else "")+text
                    if bool_group:
                        integer = group_numbers_decimal(integer)
                    insert(integer+","+decimal)
                else:
                    self.position_insert_numb = "decimal"
            else:
                if len(decimal) < self.max_len_decimals:
                    delete()
                    if decimal == "0":
                        if text != "0":
                            decimal = ""
                    decimal = (decimal)+text
                    insert(integer+","+decimal)
                    
        elif numeral == 2:
            #binary
            text_nw = ungroup_numbers_x4((actual_text if actual_text != "0" else "") + text)
            if len(text_nw) <= self.max_len_binary:
                delete()
                if bool_group:
                    text_nw = group_numbers_x4(text_nw)
                insert(text_nw)

        elif numeral == 4:
            #hexadecimal
            text_nw = ungroup_numbers_x4((actual_text if actual_text != "0" else "") + text)
            if len(text_nw) <= self.max_len_hexadecimal:
                delete()
                if bool_group:
                    text_nw = group_numbers_x4(text_nw)
                insert(text_nw)
    
        else:
            #octal
            text_nw = ungroup_numbers_octal((actual_text if actual_text != "0" else "") + text)
            if len(text_nw) <= self.max_len_octal:
                delete()
                if bool_group:
                    text_nw = group_numbers_octal(text_nw)
                insert(text_nw)
        self.entry_numerals["state"] = "readonly"

    def change_state(self, option_state):
        self.button_add_1["state"] = option_state["1"]
        self.button_add_2["state"] = option_state["2"]
        self.button_add_3["state"] = option_state["3"]
        self.button_add_4["state"] = option_state["4"]
        self.button_add_5["state"] = option_state["5"]
        self.button_add_6["state"] = option_state["6"]
        self.button_add_7["state"] = option_state["7"]
        self.button_add_8["state"] = option_state["8"]
        self.button_add_9["state"] = option_state["9"]
        self.button_add_0["state"] = option_state["0"]
        for button_hex in "abcdef":
            eval("self.button_add_"+button_hex)["state"] = option_state["button_hex"]
        self.button_add_value_e["state"] = option_state["ee"]
        self.button_add_value_pi["state"] = option_state["pi"]
        self.button_sqrt["state"] = option_state["sqrt"]

    def change_type_numerals(self):
        numeral = self.bool_numerals.get()
        self.clear_numerals()
        state_buttons = {}
        if numeral == 1:
            self.expression_avalaible = "0123456789"
            for char in self.expression_avalaible:
                state_buttons[char] = NORMAL
            state_buttons["button_hex"] = DISABLED
            for char in ("ee", "pi", "sqrt"):
                state_buttons[char] = NORMAL
            self.position_insert_numb = "integer"
            
        elif numeral == 2:
            self.expression_avalaible = "01"
            for char in self.expression_avalaible:
                state_buttons[char] = NORMAL
            state_buttons["button_hex"] = DISABLED
            for char in "23456789":
                state_buttons[char] = DISABLED
            for char in ("ee", "pi", "sqrt"):
                state_buttons[char] = DISABLED
                
        elif numeral == 3:
            self.expression_avalaible = "01234567"
            for char in self.expression_avalaible:
                state_buttons[char] = NORMAL
            state_buttons["button_hex"] = DISABLED
            for char in ("ee", "pi", "8", "9", "sqrt"):
                state_buttons[char] = DISABLED
                
        elif numeral == 4:
            self.expression_avalaible = "01234567890abcdef"
            for char in "01234567890":
                state_buttons[char] = NORMAL
            for char in ("ee", "pi", "sqrt"):
                state_buttons[char] = DISABLED
            state_buttons["button_hex"] = NORMAL
        self.change_state(state_buttons)

    def resolve_problem_x1numerals(self, oper):
        actual_text = self.entry_numerals.get()
        sign = "-" if actual_text[0] == "-" else ""
        if sign: actual_text = actual_text[1:]
        numeral = self.bool_numerals.get()
        bool_group = self.bool_view_group.get()
        if numeral == 1:
            if oper == bit_not:
                result = str(oper(int(sign+ungroup_numbers_decimal(actual_text.split(",")[0]))))
            else:
                result = str(oper(float(sign+ungroup_numbers_decimal(actual_text).replace(",", "."))))
            if bool_group:
                result = group_numbers_decimal(result)
        elif numeral == 2:
            integer = int(int_binary(sign+ungroup_numbers_binary(actual_text)))
            result = binary(str(oper(integer)))
            #max = intbinary) INCO;PLETARSSS
            if bool_group:
                result = group_numbers_x4(result)
        elif numeral == 3:
            result = oct(oper(eval(sign+"0"+ungroup_numbers_octal(actual_text))))[1:]
            max = eval("0"+"7"*self.max_len_octal)
            if eval(result) > max:
                result = "7"*self.max_len_octal
            if bool_group:
                result = group_numbers_octal(result)
        elif numeral == 4:
            result = hex(oper(eval(sign+"0x"+ungroup_numbers_x4(actual_text)))).replace("0x", "").replace("L", "").upper()
            max = eval("0x"+"F"*self.max_len_hexadecimal)
            if eval("0x"+result) > max:
                result = "F"*self.max_len_hexadecimal
            if bool_group:
                result = group_numbers_x4(result)
        self.entry_numerals["state"] = NORMAL
        self.entry_numerals.delete(0, END)
        self.entry_numerals.insert(0, result)
        self.entry_numerals["state"] = "readonly"
    

    def to_square(self):
        self.resolve_problem_x1numerals(square)

    def to_bit_not(self):
        self.resolve_problem_x1numerals(bit_not)
                
            
machine = Body()
machine.root.mainloop()
  
Hice sientos de cosas para hacer esta calculadora, la hice yo solo desde el principio, nadie me ayudo, quiero que se animen a probar esa interfaz, les aseguro que no encuentran calculadoras asi. Le copie el sistema a la calculadora de windows (sistema de entrada de datos).
Soporta binario, hex, decimal y octal, pudiendo agrupar los numeros como 1111 1111 1111 - 111.111.111,221 o AAAA FFFA 1DD...

NelsonPP, xRodak, el comando config o configure, funciona en cualquier Widget (elemento de ventana), para poder configurar cualquier opcion que fue o no pasada en el argumento **KW, pero no a los parametros como master,

EJ: def __init__(master=None, *cnf, **kw):
...

A esas opciones que se pueden configurar con "config" tambien se las puede configurar como si de un diccionario se tratara nuestro widget:

label["text"] = "nuevo texto";

que es igual que

config(text = "nuevo texto");

... osea que, podemos obtener el valor de la opcion "text" con hacer

opt = label["text"];

o

opt = label.config("text");

NelsonRP, te recomiendo que busques en internet como usar eventos en Tkinter, para poder usar no solo <Return>, si no poder usar tambien teclas como alt-ctrl-esc o cosas asi que hoy en dia estoy olvidando.

xRodak, la funcion que se le pasa a widget.bind("<Return>", func); acepta un parametro como vos decias. Te explico que hace ese parametro.

Código:
from Tkinter import *

ventana = Tk();

def imprimir(evento=None):
    if evento:
        tecla = evento.keysym;
        print tecla

ventana.bind("<Return>", imprimir);
  
... el parametro recibe informacion del evento, tenes que mirar mas referencias para saber que mas informacion podes sacarle al evento, todo depende del tipo de evento.

Saludos!
__________________

sokoleonardo está desconectado   Responder Citando
El Siguiente Usuario Agradeció a sokoleonardo Por Este Mensaje:
NelsonRP (19-sep-2012)
Antiguo 19-sep-2012, 09:34   #5
Recien llegado
 
Fecha de Ingreso: julio-2012
Amigos 0
Mensajes: 24
Gracias: 1
Agradecido 1 vez en 1 mensaje.
Predeterminado Respuesta: Python 2 Tkinter label destroy

Gracias por aclararme lo del parámetro, la verdad, yo he estudiado python por mi mismo, y en la universidad que vi solo lo básico, por lo que hay muchos detalles que desconozco, se aprecia esa información.

Gracias !
xRodak está desconectado   Responder Citando
Antiguo 19-sep-2012, 14:51   #6
Recien llegado
 
Fecha de Ingreso: abril-2012
Amigos 0
Mensajes: 9
Gracias: 4
Agradecido 0 veces en 0 mensajes.
Predeterminado Respuesta: Python 2 Tkinter label destroy

Gracias, Ahora pude resolver lo de hacer que Return me funcione en todas las funciones. Ahora mi ultima pregunta no la respondieron. Que puedo hacer por los errores de matematica. sokoleonardo, intentaste responderme, pero no te entendi o no me entendiste. Mi problema no es que el usuario me ponga un cero. Mi problema es que hay ciertos decimales que no tienen su equivalente en la matematica binario. Y cuando le toca al programa uno de esos decimales, me da el resultado incorecto. Por ej. Si pones en IDLE 1/12 te va a dar el resultado 0. Tambien si le pones 0.01/0.1 el resultado te da 0.09999999999999999. Hay otra solucion para esto aparte de cambiar mi convertidor a Python 3?
NelsonRP está desconectado   Responder Citando
Antiguo 19-sep-2012, 15:43   #7
Moderador
 
Avatar de ajr784
 
Fecha de Ingreso: marzo-2007
Amigos 5
Mensajes: 1.436
Gracias: 17
Agradecido 261 veces en 232 mensajes.
Predeterminado Respuesta: Python 2 Tkinter label destroy

@soko, sos un groso. Pocas veces vi a alguien que la descosa tanto con TK :P

@NelsonRP, güelcom a una sesión interactiva de python:
Código:
~$ python
>>> 1/12
0
>>> 1/12.0
0.08333333333333333
>>>
  
mmmmmmmta madre. ¿qué corno pasa?....
Código:
>>> a = 1
>>> b = 12
>>> a/b
0
>>>
  
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, y ahora?
Código:
>>> a/float(b)
0.08333333333333333
>>>
  
TUYE!, en python (la verdad que no se si eso es así en python3, peldón, en C es igual), cuando uno divide un entero por un entero, el resultado es otro número entero, cuando uno transforma 0.08(3) (el 3 en paréntesis significa periódico) a entero el resultado es 0, para que la división sea un número de coma flotante (un número real, la verdad que no se bien por qué esa denominación de coma flotante) (léase float, o double en otro lenguaje para mayor precisión) es necesario que uno de los dos operadores sea un número float, ésto no sólo sucede con la división, es con cualquier operación matemática, lo que sucede es que la división es la primer operación matemática que si uno divide números que pertenecen al conjunto de los números enteros (Z ), el resultado es un número que no pertenece al conjunto de los números enteros, sino al conjunto de los números racionales (Q )

Código:
>>> type(3*3)
<type 'int'>
>>> type(3*3.0)
<type 'float'>
>>>
  
__________________
Hay pocas frases que me identifican tanto
Cita:
Iniciado por Cuarteto de Nos
Casi nunca veo la foto
Tuya en mi celular
Sigue ahí por la pereza
Que me da apretar "borrar"
-Enamorado Tuyo-
ajr784 está desconectado   Responder Citando
El Siguiente Usuario Agradeció a ajr784 Por Este Mensaje:
NelsonRP (20-sep-2012)
Antiguo 19-sep-2012, 15:54   #8
Veterano
 
Avatar de sokoleonardo
 
Fecha de Ingreso: febrero-2011
Ubicación: C:\Argentina\Chaco\Fontana.py
Amigos 7
Mensajes: 655
Gracias: 128
Agradecido 122 veces en 75 mensajes.
Predeterminado Respuesta: Python 2 Tkinter label destroy

Cita:
Iniciado por NelsonRP Ver Mensaje
Gracias, Ahora pude resolver lo de hacer que Return me funcione en todas las funciones. Ahora mi ultima pregunta no la respondieron. Que puedo hacer por los errores de matematica. sokoleonardo, intentaste responderme, pero no te entendi o no me entendiste. Mi problema no es que el usuario me ponga un cero. Mi problema es que hay ciertos decimales que no tienen su equivalente en la matematica binario. Y cuando le toca al programa uno de esos decimales, me da el resultado incorecto. Por ej. Si pones en IDLE 1/12 te va a dar el resultado 0. Tambien si le pones 0.01/0.1 el resultado te da 0.09999999999999999. Hay otra solucion para esto aparte de cambiar mi convertidor a Python 3?
NelsonRP, yo podria resolver el problema del Entry (que el usuario pueda ingresar solo lo que el programa acepta), pero no se como decirtelo, tendria que darte el codigo armado por mi mismo, eso lo tenes que hacer vos.

La cosa consiste en que cada vez que el usuario ingrese una tecla al programa se compare lo que esta escrito y se modifique segun sea necesario. Como te dije, mira mi calculadora que postie.

Yo no se nada de "Python 3", solamente de Python2.x.

@Arj784, gracias, ahora talvez termine mi tutorial de Tkinter, el problema es que no se si muchos lo usaran, poro eso detuve el tutorial que mensione hace tiempo a David Novikov.

Saludos!
__________________

sokoleonardo está desconectado   Responder Citando
El Siguiente Usuario Agradeció a sokoleonardo Por Este Mensaje:
NelsonRP (20-sep-2012)
Antiguo 20-sep-2012, 11:33   #9
Recien llegado
 
Fecha de Ingreso: abril-2012
Amigos 0
Mensajes: 9
Gracias: 4
Agradecido 0 veces en 0 mensajes.
Predeterminado Respuesta: Python 2 Tkinter label destroy

Gracias ajr784. Yo ahora me acuerdo de eso y solucione la primera parte para que 1/12.0 tenga el resultado correcto. La otra parte de 0.01/0.1 (y tambien me di cuenta que 0.000001/0.01 sale erroneo igual) lo podria resolver de la forma que dice sokoleonardo pero es muy complicado para mi y tambien le limitaria la calculadora a que ciertos numeros no lo puede hacer. Tambien pille otra manera de hacerlo. Cada vez que pillo un error le pongo un if de que si el usuario entro lo que causa este error, le dara el resultado que yo le pongo al programa y no lo calculara por si mismo. Por Ej. asi.
Código:
if w==0.0001:
    if x==0.000001:
        y=0.01
else:
    y = x/w*v
  
Gracias a todos, ahora estoy satisfecho.
NelsonRP está desconectado   Responder Citando
Antiguo 21-sep-2012, 07:14   #10
Veterano
 
Avatar de sokoleonardo
 
Fecha de Ingreso: febrero-2011
Ubicación: C:\Argentina\Chaco\Fontana.py
Amigos 7
Mensajes: 655
Gracias: 128
Agradecido 122 veces en 75 mensajes.
Predeterminado Respuesta: Python 2 Tkinter label destroy

Cita:
Iniciado por NelsonRP Ver Mensaje
Gracias ajr784. Yo ahora me acuerdo de eso y solucione la primera parte para que 1/12.0 tenga el resultado correcto. La otra parte de 0.01/0.1 (y tambien me di cuenta que 0.000001/0.01 sale erroneo igual) lo podria resolver de la forma que dice sokoleonardo pero es muy complicado para mi y tambien le limitaria la calculadora a que ciertos numeros no lo puede hacer. Tambien pille otra manera de hacerlo. Cada vez que pillo un error le pongo un if de que si el usuario entro lo que causa este error, le dara el resultado que yo le pongo al programa y no lo calculara por si mismo. Por Ej. asi.
Código:
if w==0.0001:
    if x==0.000001:
        y=0.01
else:
    y = x/w*v
  
Gracias a todos, ahora estoy satisfecho.
NelsonRP, decime los datos que el usuario deberia entrar a un Entry, y yo te hago un Entry. Decime que tipo de decimal, que tipo de dato, etc.

Saludos!
__________________

sokoleonardo está desconectado   Responder Citando
Respuesta

Herramientas
Desplegado

Normas de Publicación
No puedes crear nuevos temas
No puedes responder mensajes
No puedes subir archivos adjuntos
No puedes editar tus mensajes

Los Códigos BB están Activado
Las Caritas están Activado
[IMG] está Activado
El Código HTML está Desactivado
Trackbacks están Activado
Pingbacks están Activado
Refbacks están Activado



Temas Similares
Tema Autor Foro Respuestas Último mensaje
<<->> Como comenzar con Python <<->> David Novikov Python 9 20-dic-2012 16:57
[Guia] Iniciando en Python Doddy Python 63 29-ago-2011 17:04
Curos de Tkinter en Español By Erik# David Novikov Python 2 28-ago-2011 16:04
<<->> LIBROS - MANUALES - EBOOKs <<->> Fashion Python 1 23-jul-2011 17:35



Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.0