How to get the width of a string in pixels?

前端 未结 2 1424
清歌不尽
清歌不尽 2021-01-02 08:24

I am using wxPython\'s HyperTreeList and I want to set the column width exactly equal to length of the largest string in it.

To accomplish that, I\'d like to to conv

2条回答
  •  天涯浪人
    2021-01-02 08:33

    It depends on how you are printing the text.

    You may be interested by PIL ImageDraw which has a textsize method. See http://effbot.org/imagingbook/imagedraw.htm

    Update: This was answering the original question. It may looks a little off-topic after question updates.

提交回复
热议问题