Muchas gracias Miguel,

Si y no.

O sea esta perfecta pero sigo con el mismo problema:

Después de:
> print('mi programa sigue por aquí')

quiero usar el texto del cuadro de dialogo para modificarlo.


un print(texto) no funciona.


Saludos,

--
Javier Pérez
http://es.linkedin.com/in/javierperez1
http://www.perasalvino.es/




> El 18 nov 2020, a las 19:12, Miguel Sanchez <msanc...@uninet.edu> escribió:
> 
> 
> 
> 
> Es esto lo que pretendes hacer?
> 
> 
> import tkinter as tk
> 
> def foo(root, texto):
>    print('con este texto "{}" hago lo que quiero'.format(texto))
>    root.quit()
>    root.destroy()
> 
> root = tk.Tk()
> root.geometry("600x400")
> 
> def getTextInput():
>    result = textExample.get("1.0", "end")
>    foo(root, result)
> 
> textExample = tk.Text(root, height=10)
> textExample.pack()
> btnRead = tk.Button(root, height=2, width=50, text="Introducir en la bbdd", 
> command=getTextInput)
> btnRead.pack()
> root.mainloop()
> 
> print('mi programa sigue por aquí')
> 
> 
> 
> Saludos
> 
> 
> 
>> 
>> 
>> 
>> 
>> Saludos,
>> 
>> --
>> Javier Pérez
>> http://es.linkedin.com/in/javierperez1
>> http://www.perasalvino.es/
>> 
>> 
>> 
>> 
>>> El 17 nov 2020, a las 18:19, Miguel Sanchez <msanc...@uninet.edu> escribió:
>>> 
>>> Hola:
>>> 
>>> 
>>> No veo claro lo que pretendes
>>> 
>>> noticia = getTextInput()
>>> print(noticia)
>>> 
>>> Están fuera del bucle por lo que se ejecutarán cuando ya no exista 
>>> textExample con lo que debería dar error
>>> y por otro lado quién esperas que reciba el return de getTextInput()??
>>> 
>>> 
>>> Saludos
>>> 
>>> 
>>> El Tue, 17 Nov 2020 12:27:16 +0100
>>> Javier Perez <javierpe...@perasalvino.es> dijo:
>>> 
>>>> Hola a todos,
>>>> 
>>>> 
>>>> Estoy empezando a usar tkinter. Tengo dos problemas:
>>>> 1) no se como sacar la información del formulario. El caso es que tengo 
>>>> una funcion que si lo recoge pero no lo retorna. No llego a entender lo 
>>>> que pasa. 
>>>> 
>>>> 2) Después, al cerrar la venta, me muestra este error la consola: 
>>>> result = textExample.get("1.0", "end")
>>>> File 
>>>> "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/tkinter/__init__.py",
>>>>  line 3706, in get
>>>> return self.tk.call(self._w, 'get', index1, index2)
>>>> _tkinter.TclError: invalid command name ".!text"
>>>> 
>>>> 
>>>> 
>>>> El código es este:
>>>> import tkinter as tk
>>>> 
>>>> root = tk.Tk()
>>>> root.geometry("600x400")
>>>> 
>>>> ​
>>>> def getTextInput():
>>>>    result = textExample.get("1.0", "end")
>>>>    #print(result) # —> si le queto el comentario si me lo imprime
>>>>     return result
>>>>    
>>>> textExample = tk.Text(root, height=10)
>>>> textExample.pack()
>>>> btnRead = tk.Button(root, height=2, width=50, text="Introducir en la 
>>>> bbdd", command=getTextInput)
>>>> 
>>>> btnRead.pack()
>>>> ​
>>>> root.mainloop()
>>>> 
>>>> noticia = getTextInput()
>>>> print(noticia)
>>>> 
>>>> 
>>>> Muchísimas gracias a todos,
>>>> 
>>>> Saludos,
>>>> 
>>>> --
>>>> Javier Pérez
>>>> http://es.linkedin.com/in/javierperez1
>>>> http://www.perasalvino.es/
>>>> 
>>>> 
>>>> 
>>>> 
>>>> _______________________________________________
>>>> Python-es mailing list
>>>> Python-es@python.org
>>>> https://mail.python.org/mailman/listinfo/python-es  
>>> _______________________________________________
>>> Python-es mailing list
>>> Python-es@python.org
>>> https://mail.python.org/mailman/listinfo/python-es  
>> 
> _______________________________________________
> Python-es mailing list
> Python-es@python.org
> https://mail.python.org/mailman/listinfo/python-es

_______________________________________________
Python-es mailing list
Python-es@python.org
https://mail.python.org/mailman/listinfo/python-es

Responder a