![Python GUI Programming Cookbook(Second Edition)](https://wfqqreader-1252317822.image.myqcloud.com/cover/163/36701163/b_36701163.jpg)
上QQ阅读APP看书,第一时间看更新
How to do it...
We add a button that, when clicked, performs an action. In this recipe, we will update the label we added in the previous recipe as well as the text property of the button:
GUI_create_button_change_property.py
![](https://epubservercos.yuewen.com/A95289/19470408908965106/epubprivate/OEBPS/Images/Code_GUI_create_button_change_property.png?sign=1739531254-nsYQeOpz4vhPX6YDltF6MyWKmd72YRD9-0-9924dba51f0f357a1847b5a3b86df78b)
The following screenshot shows how our GUI looks before clicking the button:
![](https://epubservercos.yuewen.com/A95289/19470408908965106/epubprivate/OEBPS/Images/GUI_create_button_before_click.png?sign=1739531254-2Vb9jtSaq9n8pasKsKvzLbyhaZ9LLoz1-0-80320f70c1416d901b8744e7730132be)
After clicking the button, the color of the label changed and so did the text of the button, which can be seen as follows:
![](https://epubservercos.yuewen.com/A95289/19470408908965106/epubprivate/OEBPS/Images/GUI_create_button_after_click.png?sign=1739531254-gfhcAOE2QPAEdXcm1S5BKXVk3WsZYfXn-0-8005da733634726089dac1480eb401de)