Python Forum
How can I get the width of a string in Python?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I get the width of a string in Python?
#13
thanks heiner55, the function "width_and_height_calculator_in_pixel" works but, there is an issue.. I'm not sure but probably the width and height values are wrong. see the picture:

[Image: 18d5eb1235200004.jpg]

Excel does not agree with the script result. the script gave me "102" for the "text width", but not Excel! for him the size is bigger. how is it possibile? then I have another question. to set the "width column" in Excel I have to specify a width in inch. following an exaple:

# set the first colum width in 11" (inch):
worksheet.set_column(0, 1, 11)
so, it's better to have the "text width" in inch and not in pixel. how can I reach my goal?
Reply


Messages In This Thread
RE: How can I get the width of a string in Python? - by aquerci - May-27-2019, 04:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python code to set column width 1418 11 8,451 Jan-20-2024, 07:20 AM
Last Post: Pedroski55
  Fixed colum width for rowLabels i Matplotlib pandabay 0 1,184 Jun-10-2023, 03:40 PM
Last Post: pandabay
  width of Unicode character Skaperen 6 4,369 Sep-27-2021, 12:41 AM
Last Post: Skaperen
  image.thumbnail(width, height) not working PCesarano 2 5,098 Apr-08-2021, 06:09 PM
Last Post: PCesarano
  fixed width numbers Skaperen 15 12,876 May-27-2019, 09:42 AM
Last Post: Skaperen
  printing text tables with consistent width Skaperen 7 13,284 Jul-01-2018, 02:34 AM
Last Post: Skaperen
  How to measure an inclined beam width and height in image using python? zyb1003 1 4,050 Nov-07-2017, 05:02 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020