擅长:python、mysql、java
<p>有一种方法你可以。。</p>
<p>使用<code>ttk.Style()</code>将按钮的背景色设置为主机的颜色。</p>
<pre><code>root_color = "red" #Just an example, can't remember the default tk window color
mainframe = tk.Tk() #or whatever mainframe is
mainframe.configure(bg = root_color)
style = ttk.Style()
style.configure('TButton', background = root_color)
backbutton = ttk.Button(mainframe, command=homereturn)
backbuttonimage=PhotoImage(file="back.gif")
backbutton.config(image=backbuttonimage)
backbutton.pack()
backbutton.grid(column=0, row=1)
</code></pre>
<p>另外,您不必在ttk按钮中指定<code>style = ..</code>,因为您正在配置ttk使用的默认<code>TButton</code>样式。如果为此按钮定义了自定义样式,则必须在按钮的关键字参数中指定。</p>
<p>一个例子是给你的按钮圆角边,而不是用图像来达到想要的效果。</p>