Los widgets de inicio de sesión se utilizan para recuperar una entrada de un usuario. Se puede crear así:
entrada = ttk.Entry (maestro, opción = valor, ...)
Código # 1: Creando un entrada del widget y obtener la entrada del usuario (obteniendo solo datos de cadena).
import
ttk
from < /código>
Tk()
# especificando geometría
)
# Esto se usa para obtener información del usuario
# y mostrarlo en el widget de entrada.
# Cualquier dato que recibamos del teclado
# será tratado como una cadena.
input_text
=
StringVar()
=
input_text, justificar
=
# tan pronto como se inicie la aplicación
entry1.focus_force()
entrada1.paquete (lado
=
lambda
: askyesno (
))
save.pack (side
=
TOP, pady
=
10
)
root.mainloop()
Salida:
En el resultado anterior, una vez que ejecuta el aparece la ventana , aparece un mensaje de confirmación preguntando si desea guardar el texto o no (el texto no se guardará, es solo usado para mostrar la funcionalidad del botón).
Código # 2: agrega estilo al texto ingresado en el widget de entrada.
# tkinter import
from
tkinter
# crear raíz
’ 200x100’
input_text
=
StringVar()
# Esta clase se usa para agregar estilo
, primer plano
=
’verde’
< código clase ="simple ">)
< clase de código = "cadena"> ’Confirmar’ save.pack (side
=
TOP, pady
Salida:
En el resultado anterior, puede notar que el color de la fuente ha cambiado, la familia de fuentes ha cambiado, el texto es la más grande de lo normal y el texto está en negrita. Esto se debe a que estamos agregando estilo al texto que ingresamos.
Esperamos que este artículo le haya ayudado a resolver el problema. Además de Tkinter | Agregar estilo al texto ingresado usando el widget ttk.Entry, consulta otros temas relacionados con Python functions.
¿Quiere sobresalir en Python? Consulte nuestra reseña de los mejores cursos en línea de Python 2023. Si está interesado en Data Science, consulte también cómo aprender programación en R.
Por cierto, este material también está disponible en otros idiomas:
- Tkinter | Agregar estilo al texto ingresado usando el widget ttk.Entry
- Italiano Tkinter | Agregar estilo al texto ingresado usando el widget ttk.Entry
- Deutsch Tkinter | Agregar estilo al texto ingresado usando el widget ttk.Entry
- Français Tkinter | Agregar estilo al texto ingresado usando el widget ttk.Entry
- Español Tkinter | Agregar estilo al texto ingresado usando el widget ttk.Entry
- Türk Tkinter | Agregar estilo al texto ingresado usando el widget ttk.Entry
- Русский Tkinter | Agregar estilo al texto ingresado usando el widget ttk.Entry
- Português Tkinter | Agregar estilo al texto ingresado usando el widget ttk.Entry
- Polski Tkinter | Agregar estilo al texto ingresado usando el widget ttk.Entry
- Nederlandse Tkinter | Agregar estilo al texto ingresado usando el widget ttk.Entry
- 中文 Tkinter | Agregar estilo al texto ingresado usando el widget ttk.Entry
- 한국어 Tkinter | Agregar estilo al texto ingresado usando el widget ttk.Entry
- 日本語 Tkinter | Agregar estilo al texto ingresado usando el widget ttk.Entry
- हिन्दी Tkinter | Agregar estilo al texto ingresado usando el widget ttk.Entry
Paris | 2023-03-30
Me estaba preparando para mi entrevista de codificación, gracias por aclarar esto - Tkinter | Agregar estilo al texto ingresado usando el widget ttk.Entry en Python no es el más simple. Lo usare en mi tesis de licenciatura
California | 2023-03-30
¿Tal vez haya otras respuestas? ¿Qué significa el Tkinter | Agregar estilo al texto ingresado usando el widget ttk.Entry significa exactamente?. Simplemente no estoy muy seguro de que sea el mejor método
Abu Dhabi | 2023-03-30
Gracias por la explicación. Estuve atascado con el Tkinter | Agregar estilo al texto ingresado usando el widget ttk.Entry durante algunas horas, finalmente lo conseguí 🤗. Comprobado ayer, ¡funciona!