Reputation: 1323
Simple question I thought I knew the answer to. How do you make it so the text lines up on the left hand side of a label? I have two labels on my window that I'm updating the text in the labels whenever I move the mouse, it's showing the x-y coordinates of the mouse(x position = ****** and y position = ******). The problem is the text is bouncing on me which indicates it isn't lined up on the left hand side of the label. I've tried anchor = 'w' but that isn't working. The text(x position = ), x position = still bounces as I move the mouse around the screen.
edit:
This is used to create the window
s = Frame(self, width=150, height=20)
s.pack_propagate(0)
s.place(x=0,y=680)
v = Label(s, fg='black',anchor='w')
This is used to update the window
v.config(text = "x-position: " + str(px),anchor='w')
s and v are set global
That code doesn't anchor the text on the left of the window. 'x-position:' moves left and right around the window depending on how many numbers follow the ': '.
Upvotes: 1
Views: 13179
Reputation: 225
Try adding the justify='left'
parameter to the label:
s = Frame(self, width=150, height=20)
s.pack_propagate(0)
s.place(x=0,y=680)
v = Label(s, fg='black',anchor='w', justify='left')
Upvotes: 0