import tkinter as tk
from tkinter import ttk
def pixeles():
measure = tk.Label(ventana, font = ("Vardana", 12), text = var.get())
measure.place(x=5, y=8)
measure.update_idletasks()
width = measure.winfo_width()
pixeles = f'"{var.get()}" tiene una ancho de {width} pixeles'
measure.config(text = pixeles)
measure.update_idletasks()
w = measure.winfo_width() + 10
h = 150
x = 700
y = 500
ventana.geometry('%dx%d+%d+%d' % (w, h, x, y))
ventana = tk.Tk()
ventana.geometry("300x150+700+500")
var = tk.StringVar()
medir = ttk.Entry(ventana, font = ("Vardana", 12), width=30,
textvariable=var)
medir.place(x=10, y=40)
boton = ttk.Button(ventana, text="Medir",
command=pixeles)
boton.place(x=110, y=80, width=80, height=40)
medir.focus()
ventana.mainloop()