按钮文本下划线选项不起作用。这是我已经试过:Tkinter - 下划线按钮文本
boldFontOpts = tkFont.Font(weight='bold')
self.boldButton = Button(self.toolbarFrame, text='B', command=self.boldfunc,
width=bWidth, height=bHeight)
self.boldButton['font'] = boldFontOpts
self.boldButton.grid(sticky=W, padx='4', row=1, column = 0)
self.underlineButton = Button(self.toolbarFrame, text='U', command=self.underlinefunc,
width=bWidth, height=bHeight)
underlineFontOpts = tkFont.Font(self.underlineButton, self.underlineButton.cget('font'))
underlineFontOpts.configure(underline=True)
self.underlineButton.configure(font=underlineFontOpts)
self.underlineButton.grid(sticky=W, padx='3', row=1, column = 1)
用于下划线按钮(不工作)的代码是摘自: Underline Text in Tkinter Label widget?
我也用了代号为大胆的按钮( ),但当weight='bold'
被替换为underline=1
或underline=True
并且所有相应的变量名称等被改变(显然)时,它不起作用。
那么,这个按钮文字怎么可以加下划线?
附加信息: - 在Mac - Python的3 - 调色剂,8.5
编辑: 我将这两行:
font = tkFont.Font(font=self.underlineButton['font'])
print(font.actual())
并在终端上面说'underline': 1
,但仍然不不显示下划线。
你是否在MAC? –
是的,我会加到问题 – Kyle