[pyar] Consulta Tkinter

patricio tula tula.patricio en gmail.com
Mar Abr 15 14:10:44 ART 2014


Muchas gracias!
Ahi funciona todo.



2014-04-15 13:55 GMT-03:00 Lucas <rollbak en gmail.com>:

> 2014-04-15 13:38 GMT-03:00 patricio tula <tula.patricio en gmail.com>:
>
> No encuentro el error. Lo leo y releo pero no lo encuentro.
>> Adjunto el código entero.
>>
>>
>>
>> 2014-04-15 13:14 GMT-03:00 Lucas <rollbak en gmail.com>:
>>
>>  2014-04-15 13:02 GMT-03:00 patricio tula <tula.patricio en gmail.com>:
>>>
>>> Ahi va una captura. La ventana esta vacio u en terminal no escribio
>>>> nada. Estoy usando Python 2.7.3, será por eso?
>>>> Ahi va el archivo en dropbox:
>>>> https://www.dropbox.com/s/9i6rgejx52k50n7/Tkinter.png
>>>>
>>>>
>>>>
>>>> 2014-04-15 12:53 GMT-03:00 patricio tula <tula.patricio en gmail.com>:
>>>>
>>>>> Ahi va una captura. La ventana esta vacio u en terminal no escribio
>>>>> nada. Estoy usando Python 2.7.3, será por eso?
>>>>>
>>>>>
>>>>> 2014-04-15 12:46 GMT-03:00 Lucas <rollbak en gmail.com>:
>>>>>
>>>>>  2014-04-15 12:26 GMT-03:00 patricio tula <tula.patricio en gmail.com>:
>>>>>>
>>>>>> Lucas gracias por contestar.
>>>>>>>
>>>>>>> Acabo de cambiar el código como me dijiste pero no cambió nada.
>>>>>>> Sigue sucediendo lo mismo. Incluso comenté el destructor y puse el
>>>>>>> constructor de prestado arriba de .get() no sirvió.
>>>>>>> Vuelvo a agregar el código.
>>>>>>> Saludos,
>>>>>>>
>>>>>>>  def PrestamosHerramientas():
>>>>>>>   9     Prestamos = Tk()
>>>>>>>  10     str1=StringVar()
>>>>>>>  11     str2=StringVar()
>>>>>>>
>>>>>>>  12     Prestamos.title("LABI-Sistema de control de
>>>>>>> prestamos-Prestamos")
>>>>>>>  13     #Nombre y apellido
>>>>>>>  14     L1=Label(Prestamos,text="Nombre y
>>>>>>> Apellido").grid(row=0,column=0)
>>>>>>>  15     E1=Entry(Prestamos,textvariable=str1,
>>>>>>> bd=5).grid(row=0,column=1)
>>>>>>>  16     #DNI
>>>>>>>  17     L2=Label(Prestamos, text="DNI").grid(row=1,column=0)
>>>>>>>  18     E2=Entry(Prestamos, textvariable=str2,bd=5).grid(row=1,
>>>>>>> column=1)
>>>>>>>  19
>>>>>>>  20     def Prestar():#TODO Arreglar, esto no anda. str1 y str2
>>>>>>> estan vacios
>>>>>>>  21         Prestado = Tk()
>>>>>>>  22         text1=str1.get()
>>>>>>>  23         text2=str2.get()
>>>>>>>  24         print text1
>>>>>>>  25         print text2
>>>>>>>  26         #Prestamos.destroy()
>>>>>>>  27         Prestado.title("Prestado")
>>>>>>>  28         PrestarNyALabel = Label(Prestado, text=text1).pack()
>>>>>>>  29         PrestarDNILabel = Label(Prestado, text=text2).pack()
>>>>>>>  30         Prestado.mainloop()
>>>>>>>  31
>>>>>>>  32     PrestarBoton = Button(Prestamos, text="PRESTAR",
>>>>>>> command=Prestar).grid(row=2,column=2)
>>>>>>>  33
>>>>>>>  34
>>>>>>>  35     Prestamos.mainloop()
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> 2014-04-15 12:11 GMT-03:00 Lucas <rollbak en gmail.com>:
>>>>>>>
>>>>>>>  2014-04-15 11:26 GMT-03:00 patricio tula <tula.patricio en gmail.com>:
>>>>>>>>
>>>>>>>>> Hola,
>>>>>>>>> Estoy diseñando un programa para controlar prestamos de
>>>>>>>>> herramientas para el laboratorio abierto de fiuba y tengo un problema con
>>>>>>>>> el  bloque de código de la interfaz gráfica agregado abajo.
>>>>>>>>> Concretamente, el problema es que las entradas de texto no se
>>>>>>>>> guardan y cuando quiero utilizar la info en otro ventana no puedo. Alguien
>>>>>>>>> tiene idea porque está pasando esto? como podría solucionarlo?
>>>>>>>>> Desde ya muchas gracias,
>>>>>>>>> Patricio
>>>>>>>>>
>>>>>>>>> PD: Aviso, soy Newbie en python todavía.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>  8 def PrestamosHerramientas():
>>>>>>>>>   9     str1=StringVar()
>>>>>>>>>  10     str2=StringVar()
>>>>>>>>>  11     Prestamos = Tk()
>>>>>>>>>  12     Prestamos.title("LABI-Sistema de control de
>>>>>>>>> prestamos-Prestamos")
>>>>>>>>>  13     #Nombre y apellido
>>>>>>>>>  14     L1=Label(Prestamos,text="Nombre y
>>>>>>>>> Apellido").grid(row=0,column=0)
>>>>>>>>>  15     E1=Entry(Prestamos,textvariable=str1,
>>>>>>>>> bd=5).grid(row=0,column=1)
>>>>>>>>>  16     #DNI
>>>>>>>>>  17     L2=Label(Prestamos, text="DNI").grid(row=1,column=0)
>>>>>>>>>  18     E2=Entry(Prestamos, textvariable=str2,bd=5).grid(row=1,
>>>>>>>>> column=1)
>>>>>>>>>  19     print str1
>>>>>>>>>  20     print str2.get()
>>>>>>>>>  21     print str2
>>>>>>>>>  22     print str1.get()
>>>>>>>>>  23     def Prestar():#TODO Arreglar, esto no anda. str1 y str2
>>>>>>>>> estan vacios
>>>>>>>>>  24         text1=str1.get()
>>>>>>>>>  25         text2=str2.get()
>>>>>>>>>  26         print str1
>>>>>>>>>  27         print str2
>>>>>>>>>  28         print text1
>>>>>>>>>  29         print text2
>>>>>>>>>  30         Prestamos.destroy()
>>>>>>>>>  31         Prestado = Tk()
>>>>>>>>>  32         Prestado.title("Prestado")
>>>>>>>>>  33         PrestarNyALabel = Label(Prestado, text=text1).pack()
>>>>>>>>>  34         PrestarDNILabel = Label(Prestado, text=text2).pack()
>>>>>>>>>  35         Prestado.mainloop()
>>>>>>>>>  36
>>>>>>>>>  37
>>>>>>>>> PrestarBoton=Button(Prestamos,text="PRESTAR",command=Prestar).grid(row=2,column=2)
>>>>>>>>>  38
>>>>>>>>>  39
>>>>>>>>>  40     Prestamos.mainloop()
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> pyar mailing list pyar en python.org.ar
>>>>>>>>> http://listas.python.org.ar/listinfo/pyar
>>>>>>>>>
>>>>>>>>> PyAr - Python Argentina - Sitio web: http://www.python.org.ar/
>>>>>>>>>
>>>>>>>>> La lista de PyAr esta Hosteada en USLA - Usuarios de Software
>>>>>>>>> Libre de Argentina - http://www.usla.org.ar
>>>>>>>>>
>>>>>>>>
>>>>>>>> Patricio,
>>>>>>>>
>>>>>>>> Tu problema es que estas creando el "top-level widget" despues de
>>>>>>>> crear los widgets de StringVar, entonces no se bindean a ningun padre.
>>>>>>>>
>>>>>>>> Pone la linea 11 al principio de tu metodo y todo deberia andar.
>>>>>>>>
>>>>>>>> Saludos,
>>>>>>>>
>>>>>>>> --
>>>>>>>> Lucas
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> pyar mailing list pyar en python.org.ar
>>>>>>>> http://listas.python.org.ar/listinfo/pyar
>>>>>>>>
>>>>>>>> PyAr - Python Argentina - Sitio web: http://www.python.org.ar/
>>>>>>>>
>>>>>>>> La lista de PyAr esta Hosteada en USLA - Usuarios de Software Libre
>>>>>>>> de Argentina - http://www.usla.org.ar
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> pyar mailing list pyar en python.org.ar
>>>>>>> http://listas.python.org.ar/listinfo/pyar
>>>>>>>
>>>>>>> PyAr - Python Argentina - Sitio web: http://www.python.org.ar/
>>>>>>>
>>>>>>> La lista de PyAr esta Hosteada en USLA - Usuarios de Software Libre
>>>>>>> de Argentina - http://www.usla.org.ar
>>>>>>>
>>>>>>
>>>>>>
>>>>>> Buenas,
>>>>>>
>>>>>> Lo probe en mi pc y esta andando [0].
>>>>>>
>>>>>> Podes copiar el output del script cuando lo corres?
>>>>>>
>>>>>> [0]
>>>>>> https://www.dropbox.com/s/9dh0rf1spy6lwzd/Screenshot%202014-04-15%2012.44.08.png
>>>>>>
>>>>>> --
>>>>>> Lucas
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> pyar mailing list pyar en python.org.ar
>>>>>> http://listas.python.org.ar/listinfo/pyar
>>>>>>
>>>>>> PyAr - Python Argentina - Sitio web: http://www.python.org.ar/
>>>>>>
>>>>>> La lista de PyAr esta Hosteada en USLA - Usuarios de Software Libre
>>>>>> de Argentina - http://www.usla.org.ar
>>>>>>
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> pyar mailing list pyar en python.org.ar
>>>> http://listas.python.org.ar/listinfo/pyar
>>>>
>>>> PyAr - Python Argentina - Sitio web: http://www.python.org.ar/
>>>>
>>>> La lista de PyAr esta Hosteada en USLA - Usuarios de Software Libre de
>>>> Argentina - http://www.usla.org.ar
>>>>
>>>
>>>
>>> Entonces el problema debe generarse con el resto de tu codigo, las
>>> funciones que mandaste andan bien. Calculo que debe haber algo del resto
>>> del codigo que esta generando el conflicto.
>>>
>>> --
>>> Lucas
>>>
>>>
>>> _______________________________________________
>>> pyar mailing list pyar en python.org.ar
>>> http://listas.python.org.ar/listinfo/pyar
>>>
>>> PyAr - Python Argentina - Sitio web: http://www.python.org.ar/
>>>
>>> La lista de PyAr esta Hosteada en USLA - Usuarios de Software Libre de
>>> Argentina - http://www.usla.org.ar
>>>
>>
>>
>> _______________________________________________
>> pyar mailing list pyar en python.org.ar
>> http://listas.python.org.ar/listinfo/pyar
>>
>> PyAr - Python Argentina - Sitio web: http://www.python.org.ar/
>>
>> La lista de PyAr esta Hosteada en USLA - Usuarios de Software Libre de
>> Argentina - http://www.usla.org.ar
>>
>
> Como sospechaba el conflicto se generaba cuando integrabas esta funcion
> con el resto del codigo.
>
> El fix:
>
> def PrestamosHerramientas():
>     Prestamos = Tk()
>     str1=StringVar(Prestamos)
>     str2=StringVar(Prestamos)
>     ....
>
> Pasa el "top-level-widget" que corresponde como padre de los widgets
> asociados.
>
> Al no pasarlo explícitamente estaban tomando como parent a la primer
> ventana que creaste, x eso cuando los accedias desde el contexto del nuevo
> "top-level-widget" estaban sin inicializar.
>
> Saludos,
> --
> Lucas
>
>
> _______________________________________________
> pyar mailing list pyar en python.org.ar
> http://listas.python.org.ar/listinfo/pyar
>
> PyAr - Python Argentina - Sitio web: http://www.python.org.ar/
>
> La lista de PyAr esta Hosteada en USLA - Usuarios de Software Libre de
> Argentina - http://www.usla.org.ar
>
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://listas.python.org.ar/pipermail/pyar/attachments/20140415/fc66ed8f/attachment-0001.html>


More information about the pyar mailing list