Set up a formatted string before you send it to the Textbox. Here is an example:
# example to set up a table formatted string
import math
# set up the format strings (use - for left justified)
header = "%-12s %-12s %-12s \n"
line_fs = "%-12f %-12.4f %-12.4f \n"
table = ''
table += (header % ('radians', 'sine', 'cosine'))
for x in range(0, 11):
rad = math.radians(x)
table += (line_fs % (rad, math.sin(rad), math.cos(rad)))
print(table)
"""my output (use a fixed font like Courier) -->
radians sine cosine
0.000000 0.0000 1.0000
0.017453 0.0175 0.9998
0.034907 0.0349 0.9994
0.052360 0.0523 0.9986
0.069813 0.0698 0.9976
0.087266 0.0872 0.9962
0.104720 0.1045 0.9945
0.122173 0.1219 0.9925
0.139626 0.1392 0.9903
0.157080 0.1564 0.9877
0.174533 0.1736 0.9848
"""
Reputation Points: 961
Solved Threads: 211
Nearly a Posting Maven
Offline 2,413 posts
since Oct 2006