Hamish
Hamish

Reputation: 513

How to centre text vertically in this button

import tkinter as tk

request_help_button = tk.Button(text='Request Help', font=('Arial Hebrew', 14),
width=25, fg='white', highlightbackground='green', borderwidth=5, highlightthickness=2)
request_help_button.pack(ipady=10, anchor=tk.CENTER)

root=tk.Tk()
root.mainloop()

How can I get the text within this button to be completely centred, both horizontally and vertically.

Right now the text seems to be unevenly centred vertically.

Upvotes: 1

Views: 72

Answers (1)

Moshe Slavin
Moshe Slavin

Reputation: 5204

I have tried to play around with the sizes of width and other params, to my eyes, it looks fine:

import tkinter as tk

root=tk.Tk()
request_help_button = tk.Button(text='בקשת עזרה', font=('Arial Hebrew', 18), width=10, fg='blue', highlightbackground='green', borderwidth=5, highlightthickness=5)
request_help_button.pack(ipady=5, anchor=tk.CENTER)

root.mainloop()

Hope this helps you!

Upvotes: 1

Related Questions