+ 1

Python: Adjusting Text Size in a Button

In my project, I encountered an issue while trying to change the text size of a button. I had defined a button with a specific text (*), but when I attempted to change the text size using the font() function, it unexpectedly affected the button's size as well. Problem: Here's the code snippet where I defined the button: myButton_multiply = Button(root, text="*", padx=44, pady=20, bg="#7FFFD4", fg="green", command=button_multiply) myButton_multiply.grid(row=5, column=0) I am grateful for the community's support and the opportunity to seek assistance. Happy coding and best wishes on all your future projects! As you can see, the text is "*", but after running it, the text looked very small for that button. Following the suggestion from ChatGBT, I tried using the font() function to change the text size of the button. However, this approach not only changed the text size but also affected the button's size, which was not the desired outcome.

28th Jul 2023, 2:21 AM
Waseem Esayed
Waseem Esayed - avatar
1 Antwort
+ 6
You could try setting the width and height properties of the button, if you want it to have a specific size. https://pythonexamples.org/JUMP_LINK__&&__python__&&__JUMP_LINK-button-tkinter-example/ https://pythonexamples.org/python-tkinter-button-change-font/
28th Jul 2023, 3:39 AM
Tibor Santa
Tibor Santa - avatar