Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/365.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中ttk.按钮使用的字体?_Python_Tkinter_Ttk - Fatal编程技术网

Python 如何确定tkinter中ttk.按钮使用的字体?

Python 如何确定tkinter中ttk.按钮使用的字体?,python,tkinter,ttk,Python,Tkinter,Ttk,我有一个ttk按钮,我想知道它的字体。使用:my\u button.cget('font')会给我\u tkinter.TclError:未知选项“-font”。好的,这意味着小部件本身没有存储字体。因此,我尝试使用my_style.cget('font')查询样式。然后结果是AttributeError:“Style”对象没有属性“cget” 这是一个密码狙击手。这次我试着直接改变字体。我知道这是calibri,但无法质疑: my_style = ttk.Style() my_style.co

我有一个ttk按钮,我想知道它的字体。使用:
my\u button.cget('font')
会给我
\u tkinter.TclError:未知选项“-font”
。好的,这意味着小部件本身没有存储字体。因此,我尝试使用
my_style.cget('font')
查询样式。然后结果是
AttributeError:“Style”对象没有属性“cget”

这是一个密码狙击手。这次我试着直接改变字体。我知道这是calibri,但无法质疑:

my_style = ttk.Style()
my_style.configure('W.TButton', background='black',
                   font=('calibri', 10, 'bold', 'underline'), foreground='white')
print(my_style.cget('font'))
使用
my_style.lookup(“W.TButton”、“font”)

使用
my_style.lookup(“W.TButton”、“font”)

您还可以使用:

my_style.configure('W.TButton', 'font')
您还可以使用:

my_style.configure('W.TButton', 'font')