[Python] How to have single word in sentence to be bold in tkinter (python)

Discussão em 'Python' iniciado por Stack, Fevereiro 12, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to display first name and last name using tkinter in python but the last name must be in bold. Since the first name vary in length, I can't use two different label and could not figure out how to calculate the length of the first name to have the last name at the right location (following the first name). Right now the code is simple but the last name is not bold!

    from tkinter import Tk, Label
    root = Tk()
    first_name = "John"
    last_name = "Doe"
    name = first_name + " " + last_name
    Label(root, text=name).place(x=100, y=100)


    Found similar issue on the internet but could not understand the code to make it work. I don't have too much experience on Python. Any help would be appreciated.

    Continue reading...

Compartilhe esta Página