December 2015
Beginner to intermediate
350 pages
6h 49m
English
This recipe extends the previous one. You can download the entire code from the Packt Publishing website.
We are adding 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 updating the text property of the button.
# Modify adding a Label # 1
aLabel = ttk.Label(win, text="A Label") # 2
aLabel.grid(column=0, row=0) # 3
# Button Click Event Callback Function # 4
def clickMe(): # 5
action.configure(text="** I have been Clicked! **")
aLabel.configure(foreground='red')
# Adding a Button # 6
action = ttk.Button(win, text="Click Me!", command=clickMe) # 7
action.grid(column=1, row=0) # 8Before
Read now
Unlock full access