要对标签小部件中的所有文本加下划线,您需要创建一个将underline属性设置为True的新字体。这是一个例子:
import Tkinter as tkimport tkFontclass App: def __init__(self): self.root = tk.Tk() self.count = 0 l = tk.Label(text="Hello, world") l.pack() # clone the font, set the underline attribute, # and assign it to our widget f = tkFont.Font(l, l.cget("font")) f.configure(underline = True) l.configure(font=f) self.root.mainloop()if __name__ == "__main__": app=App()


