Take the 2-minute tour ×

I am looking for a way to right justify my string. This is my code:

from graphics import*

def main():

    win = GraphWin("Simple Editor", 600, 400)

    #Text - Filename
    s = "File Name:"
    text1 = Text(Point(10, 35), s)
    #Text - Keyword
    s1 = "Keyword:"
    text2 = Text(Point(10, 28), s1)
    #Text - Replace with
    s2 = "Replace with:"
    text2 = Text(Point(10, 21), s2)


The .rjust() commands does not seem to be anything. When I run the program, they still center the text on the point that i gave them, and not right justifying on that point. I cannot find a solution to this, please help!

share|improve this question

1 Answer 1

First, you have to use same width for all of the .rjust() what is big enough to contain the longest string in the column. For example 14.

Second, you have to use fixed width font because with proportional fonts you can't align precisely by characters.

Third, you should use graphics class's right align function instead of the string based .rjust(). It seems this graphics class doesn't have this functionality so you should use .rjust() and fixed width fonts or you should use another graphics library.

I hope it helps. :)

share|improve this answer

Your Answer


