Measuring string width in Python -


i have font (times new roman, 14) , need measure string width. found matplotlib , example api:

from matplotlib import rcparams import os.path afm_filename = os.path.join(rcparams['datapath'], 'fonts', 'afm',                 'ptmr8a.afm') matplotlib.afm import afm afm = afm(open(afm_filename)) afm.string_width_height('what heck?') 

but can't understand should paste instead of "datapaths", "fonts", "afm". way sting width in python? maybe way?

import tkinter tkinter  tkinter import font tkfont  tkinter.frame().destroy() txt = tkfont.font(family="times new roman", size=14) width = txt.measure("what heck?") print(width) 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -