Underline Text in Tkinter Label widget?

后端 未结 7 752
天命终不由人
天命终不由人 2020-12-20 12:30

I am working on a project that requires me to underline some text in a Tkinter Label widget. I know that the underline method can be used, but I can only seem to get it to u

7条回答
  •  清歌不尽
    2020-12-20 13:17

    To underline all the characters you should import tkinter.font and make your own font style with this. Example-

    from tkinter import *
    from tkinter.font import Font
    rt=Tk()
    myfont=Font(family="Times",size=20,weight="bold", underline=1)
    Label(rt,text="it is my GUI".title(),font=myfont,fg="green").pack()
    rt.mainloop()
    

提交回复
热议问题