<p><code>btn</code>只是一个值字典,让我们看看接下来会发生什么:</p>
<pre><code>#lets do another button example
Search_button
<tkinter.Button object .!button>
#hmm, lets do dict(Search_button)
dict(Search_button)
{'activebackground': 'SystemButtonFace', 'activeforeground':
'SystemButtonText', 'anchor': 'center', 'background': 'SystemButtonFace',
'bd': <pixel object: '2'>, 'bg': 'SystemButtonFace', 'bitmap': '',
'borderwidth': <pixel object: '2'>, 'command': '100260920point', 'compound':
'none', 'cursor': '', 'default': 'disabled', 'disabledforeground':
'SystemDisabledText', 'fg': 'SystemButtonText', 'font': 'TkDefaultFont',
'foreground': 'SystemButtonText', 'height': 0, 'highlightbackground':
'SystemButtonFace', 'highlightcolor': 'SystemWindowFrame',
'highlightthickness': <pixel object: '1'>, 'image': '', 'justify': 'center',
'overrelief': '', 'padx': <pixel object: '1'>, 'pady': <pixel object: '1'>,
'relief': 'raised', 'repeatdelay': 0, 'repeatinterval': 0, 'state':
'normal', 'takefocus': '', 'text': 'Click me for 10 points!',
'textvariable': '', 'underline': -1, 'width': 125, 'wraplength': <pixel
object: '0'>}
#this will not work if you have closed the tkinter window
</code></pre>
<p>如您所见,它是一个很大的值字典,因此如果您想更改任何按钮,只需执行以下操作:</p>
<pre><code>Button_that_needs_to_be_changed["text"] = "new text here"
</code></pre>
<p>真的是这样!</p>
<p>它会自动更改按钮上的文本,即使您处于空闲状态!</p>