Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/353.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Tkinter-下划线按钮文本_Python_Button_Tkinter - Fatal编程技术网

Python Tkinter-下划线按钮文本

Python Tkinter-下划线按钮文本,python,button,tkinter,Python,Button,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.boldButt

按钮文本下划线选项不起作用。这就是我尝试过的:

    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)
下划线按钮(不起作用)使用的代码取自:

我还在下划线按钮中使用了粗体按钮的代码(它可以工作),但是当
weight='bold'
underline=1
underline=True
替换,并且所有适当的变量名等都被更改(显然)时,它就不起作用了

那么,这个按钮文本如何加下划线呢

其他信息: -在mac上 -Python 3 -着色剂8.5

编辑: 我添加了这两行:

font = tkFont.Font(font=self.underlineButton['font'])
print(font.actual())

在终端上显示“下划线”:1,但仍然不显示下划线。

创建按钮时,请尝试执行以下操作:

button = Button(window, text="Sample", font= "Verdana 10 underline")
然后将按钮的字体设置为带下划线的样式


希望我能帮忙

是的,我会添加到问题中,但仍然没有显示下划线,如果我更改您的代码并将其设置为粗体。嗯,我想这是因为您在Mac上,请尝试查看一些TKfont文档,抱歉,我没有太多帮助!我真的无法探究你的问题。请复习。不鼓励只使用代码的答案,因为它们没有解释如何解决问题。你应该更新你的答案来解释它的作用以及它是如何解决问题的。
tkinter.Button(self, text='Reset',relief='flat',font=('Verdana', 9,'bold','underline'))