khushi
khushi

Reputation: 365

Is it possible to center text in a button?

User_button=Button(root,text = "User", anchor = W)              
User_button.configure(width = 50,height = 8, bg = "black", fg = "blue", border = 10 )           
User_button = canvas.create_window(42, 150, anchor=NW, window=User_button)

This is my code for my button - I want the text User to be in the middle of the button (the button has to be big so the text looks a bit weird sticking to one side). Is that possible?

Upvotes: 0

Views: 69

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 385980

Text on buttons should be centered by default. In the code you posted you're explicitly forcing it to be left-justified with anchor = W. Just remove the setting of anchor or set it to "center" (or the constant CENTER, which is set to the string "center").

Upvotes: 2

Related Questions