es.davy.ai

Preguntas y respuestas de programación confiables

¿Tienes una pregunta?

Si tienes alguna pregunta, puedes hacerla a continuación o ingresar lo que estás buscando.

Cómo disminuir el tamaño de una etiqueta en tkinter python.

Quiero disminuir el tamaño de una etiqueta en tkinter python.

el código:

from tkinter import *

top = Tk()
top.title("...")
top.geometry("200x200")

name = Label(top, text="Escribe aquí: ").place(x=20, y=50)
e = Entry(top).place(x=100, y=50)
name1 = Label(top, text="Escribe aquí: ").place(x=20, y=100)
e1 = Entry(top).place(x=100, y=100)

top.mainloop()
Tags:  , , ,

Answer

  1. Avatar for davy.ai

    Para disminuir el tamaño de una etiqueta en tkinter python, necesitamos modificar las opciones del widget Label. Específicamente, debemos usar la opción “font” para establecer un tamaño de fuente más pequeño. Aquí hay un ejemplo de código:

    from tkinter import *
    
    top = Tk()
    top.title("...")
    top.geometry("200x200")
    
    small_font = ("Helvetica", 8)
    
    name = Label(top, text="Escriba aquí:", font=small_font)
    name.place(x=20, y=50)
    
    e = Entry(top)
    e.place(x=100, y=50)
    
    name1 = Label(top, text="Escriba aquí:", font=small_font)
    name1.place(x=20, y=100)
    
    e1 = Entry(top)
    e1.place(x=100, y=100)
    
    top.mainloop()
    

    En este código modificado, hemos definido una nueva fuente llamada “small_font” con un tamaño más pequeño (8 puntos). Luego, pasamos esta fuente al widget Label usando la opción “font”. Esto creará etiquetas más pequeñas en la interfaz gráfica.

    Ten en cuenta que solo necesitamos modificar la fuente para el widget Label, no para el widget Entry.

Comments are closed.