Topic: Three-figure bearings - how to display leading zeros?

I have a parameter n to represent the bearing, going from 0 to 360.

I have a text box displaying the value of n : Bearing = %(n)

But how can I get it to display "00"n when n < 10 and "0"n when 10 < n < 100?

Re: Three-figure bearings - how to display leading zeros?

I have attached a plugin, which you can install in the beta version of Graph 4.5 with the Plugin Manager.
It will allow you to use the Python format function in a text label. For example you can write: Bearing = %format("n", "03.0f")
It will show the value of n with at width of at least 3, fill '0' in front of the value if needed and show no decimals.

You can find more information about how to use the format specification here:
https://docs.python.org/3/library/strin … formatspec

Post's attachments

Attachment icon TextFormatting.py 1.88 kb, 4 downloads since 2021-04-04 

Re: Three-figure bearings - how to display leading zeros?

Thank you Ivan, you are very helpful.