I have a customtkinter button which looks like this.
Is there a way I can format parts of this button text? For example, I want the first line ("Decline Dumbell Press"), to be bold, and the text on the second line ("Sets: 3, Reps: 8") to be italic. Can this be done in the same button?
Here is a screenshot of my code.
exerciseSliced = "Dumbell Press"
sets="3"
reps="8"
button_text = exerciseSliced + "\n" + "Sets: " + sets + " Reps: " + reps
exerciseButton = customtkinter.CTkButton(master=tabName, text=button_text, width=525, height=70, corner_radius=10, fg_color=t.frameColours, command=lambda text=exercise: workoutDescription(text), font=t.textFont2)
exerciseButton.grid(pady=0, padx=0)
Here are some of the things I have tried.
1. ANSI escape sequences
variable = "The bold text is",'\033[1m' + 'Python' + '\033[0m'
b1 = tk.Button(f1, text=variable, width=100, height=5)
b1.pack()
This provides the following output
2. Created a colour class
class color:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
END = '\033[0m'
variable = "The output is:" + color.BOLD + 'Python Programming !' + color.BLUE
b1 = tk.Button(f1, text=variable, width=100, height=5)
b1.pack()
3. I have also tried HTML tags, which did not work.