【发布时间】:2016-03-13 00:37:18
【问题描述】:
按钮文本下划线选项不起作用。这是我尝试过的:
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 上 - 蟒蛇 3 - 着色 8.5
编辑: 我添加了这两行:
font = tkFont.Font(font=self.underlineButton['font'])
print(font.actual())
在终端显示'underline': 1,但仍不显示下划线。
【问题讨论】:
-
是的,我会补充问题