PPaste!

for shalini

Home - All the pastes - Authored by Thooms

Raw version

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from tkinter import *  # I don't recommend using global import. better use "import tkinter as tk"


def changeColor(btn):
    # Use your own highlight background argument here instead of bg
    btn.configure(bg='#f00')


root = Tk()

button1=Button(root,text="A1",width=8, command=lambda: changeColor(button1))
button1.grid(row=0,column=0)

button2=Button(root,text="A2",width=8, command=lambda: changeColor(button2))
button2.grid(row=0,column=1)

Label(root,text=" ",padx=20).grid(row=0,column=2)

button22=Button(root,text="A3",width=8, command=lambda: changeColor(button22))
button22.grid(row=0,column=3,sticky='E')

button23=Button(root,text="A4",width=8, command=lambda: changeColor(button23))
button23.grid(row=0,column=4,sticky='E')

root.mainloop()