Título: Problema en python
Publicado por: Darui803 en 9 Septiembre 2015, 19:25 pm
Buenas tengo un error en python2.7 trabajo en Debian 8.2 con KDE.import Tkinter apl = Tkinter.Tk() texto = Label(apl, text="Hola Mundo!") texto.pack() apl.mainloop()
Este es el error No protocol specified No protocol specified Traceback (most recent call last): File "grafico.py", line 3, in <module> apl = Tkinter.Tk() File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1813, in __init__ self.tk = __tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) _tkinter.TclError: couldn't connect to display ":0"
Título: Re: Problema en python
Publicado por: DeMoNcRaZy en 9 Septiembre 2015, 19:48 pm
Prueba así: #Ventana from Tkinter import * import tkMessageBox def suma(): try: n1 = float(nombre_entry.get()) n2 = float(last_entry.get()) resultado = n1 + n2 tkMessageBox.showinfo('Mensaje', 'El resultado de la suma es: %2.f' %resultado) except ValueError: tkMessageBox.showinfo('Error', 'El valor introducido no es un numero.') nombre_entry.delete(0, 20) last_entry.delete(0, 20) ventana = Tk() ventana.title('Ventana en Python') ventana.geometry("250x160") ventana.resizable(width=FALSE, height=FALSE) widget = Label(ventana, text='Numero 1: ') widget.grid(row=1,column=1) nombre_str = StringVar() nombre_entry = Entry(ventana,textvariable=nombre_str) nombre_entry.grid(row=1,column=2) last_label= Label(ventana,text="Numero 2: ") last_label.grid(row=2,column=1) last_str = StringVar() last_entry = Entry(ventana,textvariable=last_str) last_entry.grid(row=2,column=2) finish = Button(ventana,text="Sumar", command = suma,width=15) finish.grid(row=4,column=2) ventana.mainloop()
Es un pequeño Script que hice hace un tiempo.. y suma los valores como una calculadora. Creo que hace lo que buscas. Espero que te sirva. Saludos.
Título: Re: Problema en python
Publicado por: Darui803 en 10 Septiembre 2015, 00:16 am
No funciono sale lo mismo :c
|