Skip to content

Commit

Permalink
right justify text
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandip117 committed Aug 20, 2024
1 parent fa46c9d commit 1fef959
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions markimg/markimg.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def run(self, options):
# Print image info
for field in info.keys():
x_pos = x_pos + line_gap
display_text = field + " : " + str(info[field])
display_text = f"{field.rjust(16)}: {str(info[field])}"
d_info[field] = info[field]
plt.text(x_pos, y_pos, display_text, color='white', fontsize=options.textSize, rotation=90)

Expand All @@ -486,20 +486,20 @@ def run(self, options):

d_femur = {}
# Print specific details about the image
rightFemurInfo = 'Right femur : ' + str(d_lengths['Right femur']) + f' {unit}'
rightFemurInfo = 'Right femur'.rjust(16) + f': {str(d_lengths['Right femur'])} {unit}'
d_femur['Right femur'] = str(d_lengths['Right femur']) + f' {unit}'
x_pos = x_pos + line_gap
plt.text(x_pos, y_pos, rightFemurInfo, color='white', fontsize=options.textSize, rotation=90)

leftFemurInfo = 'Left femur : ' + str(d_lengths['Left femur']) + f' {unit}'
leftFemurInfo = 'Left femur'.rjust(16) + f': {str(d_lengths['Left femur'])} {unit}'
d_femur['Left femur'] = str(d_lengths['Left femur']) + f' {unit}'
x_pos = x_pos + line_gap
plt.text(x_pos, y_pos, leftFemurInfo, color='white', fontsize=options.textSize, rotation=90)

femurDiffInfo = str(self.getDiff(d_lengths['Right femur'], d_lengths['Left femur'])) + f' {unit}, ' + \
self.compareLength(d_lengths['Left femur'], d_lengths['Right femur'])

femurDiffText = 'Difference : ' + femurDiffInfo
femurDiffText = 'Difference'.rjust(16) + f': {femurDiffInfo}'
d_femur['Difference'] = femurDiffInfo
x_pos = x_pos + line_gap
plt.text(x_pos, y_pos, femurDiffText, color='white', fontsize=options.textSize, rotation=90)
Expand All @@ -509,20 +509,20 @@ def run(self, options):
plt.text(x_pos, y_pos, '', color='white', fontsize=options.textSize, rotation=90)

d_tibia = {}
rightTibiaInfo = 'Right tibia : ' + str(d_lengths['Right tibia']) + f' {unit}'
rightTibiaInfo = 'Right tibia'.rjust(16) + f': {str(d_lengths['Right tibia'])} {unit}'
d_tibia['Right tibia'] = str(d_lengths['Right tibia']) + f' {unit}'
x_pos = x_pos + line_gap
plt.text(x_pos, y_pos, rightTibiaInfo, color='white', fontsize=options.textSize, rotation=90)

leftTibiaInfo = 'Left tibia : ' + str(d_lengths['Left tibia']) + f' {unit}'
leftTibiaInfo = 'Left tibia'.rjust(16) + f': {str(d_lengths['Left tibia'])} {unit}'
d_tibia['Left tibia'] = str(d_lengths['Left tibia']) + f' {unit}'
x_pos = x_pos + line_gap
plt.text(x_pos, y_pos, leftTibiaInfo, color='white', fontsize=options.textSize, rotation=90)

tibiaDiffInfo = str(self.getDiff(d_lengths['Right tibia'], d_lengths['Left tibia'])) + f' {unit}, ' + \
self.compareLength(d_lengths['Left tibia'], d_lengths['Right tibia'])

tibaiDiffText = 'Difference : ' + tibiaDiffInfo
tibaiDiffText = 'Difference'.rjust(16) + f': {tibiaDiffInfo}'
d_tibia['Difference'] = tibiaDiffInfo
x_pos = x_pos + line_gap
plt.text(x_pos, y_pos, tibaiDiffText, color='white', fontsize=options.textSize, rotation=90)
Expand All @@ -531,14 +531,14 @@ def run(self, options):
plt.text(x_pos, y_pos, '', color='white', fontsize=options.textSize, rotation=90)

d_total = {}
totalRightInfo = 'Total right : ' + str(
self.getSum(d_lengths['Right femur'], d_lengths['Right tibia'])) + f' {unit}'
totalRightInfo = 'Total right'.rjust(16) + f': {str(
self.getSum(d_lengths['Right femur'], d_lengths['Right tibia']))} {unit}'
d_total['Total right'] = str(self.getSum(d_lengths['Right femur'], d_lengths['Right tibia'])) + f' {unit}'
x_pos = x_pos + line_gap
plt.text(x_pos, y_pos, totalRightInfo, color='white', fontsize=options.textSize, rotation=90)

totalLeftInfo = 'Total left : ' + str(
self.getSum(d_lengths['Left femur'], d_lengths['Left tibia'])) + f' {unit}'
totalLeftInfo = 'Total left'.rjust(16) + f': {str(
self.getSum(d_lengths['Left femur'], d_lengths['Left tibia']))} {unit}'
d_total['Total left'] = str(self.getSum(d_lengths['Left femur'], d_lengths['Left tibia'])) + f' {unit}'
x_pos = x_pos + line_gap
plt.text(x_pos, y_pos, totalLeftInfo, color='white', fontsize=options.textSize, rotation=90)
Expand All @@ -549,7 +549,7 @@ def run(self, options):
self.getSum(d_lengths['Right femur'], d_lengths['Right tibia']))

totalDiffInfo = str(totalDiff) + f' {unit}, ' + totalComp
totalDiffText = 'Total difference : ' + totalDiffInfo
totalDiffText = 'Total difference'.rjust(16) + f': {totalDiffInfo}'
d_total['Difference'] = totalDiffInfo
x_pos = x_pos + line_gap
plt.text(x_pos, y_pos, totalDiffText, color='white', fontsize=options.textSize, rotation=90)
Expand Down

0 comments on commit 1fef959

Please sign in to comment.