擅长:python、mysql、java
<p>一个简单的方法是给按钮一个不可见的1x1像素图像。这样做时,<code>width</code>和<code>height</code>属性被解释为像素(或者更准确地说,<em>屏幕单位</em>,也可以是点、英寸或厘米)。</p>
<p>如果这样做,可以将<code>compound</code>设置为值“c”,表示按钮应该同时显示文本和图像,并且两者都位于窗口的中心。</p>
<p>例如:</p>
<pre><code>import Tkinter as tk
...
pixel = tk.PhotoImage(width=1, height=1)
button = tk.Button(root, text="", image=pixel, width=100, height=100, compound="c")
...
</code></pre>