flash(): Button flashing


Tkinter Button flash()


Draw the user attention by using flash() method of the Button. We have to add one active option colour to the button so while flashing the button will flash several times between normal and active colours.

Example of flash() method

Here we are having two buttons, user must click the second button saying Click Me to Agree before clicking the Submit button.
If the user clicks the Submit button without Clicking the Agree button then this button will flash several times drawing the user attention to click it.

Tkinter Button flash() method to draw user attention by blinking using active background colors


Full code is here
import tkinter as tk
my_w = tk.Tk()
my_w.geometry("400x200") # width and height of the window 
font1=('Times',22,'normal') # declaring  font Family, size and style

def my_upd():
    if b2['text']=='Click Me to Agree': # check the text of 2nd button 
        b2.flash() # flashing the button 
    else:
        b2['text']='Click Me to Agree' # change the text on the button 
    
b1=tk.Button(my_w,text='Submit',font=font1,bd=6,command=my_upd)
b1.grid(row=0,column=1,padx=10,pady=60) 

b2=tk.Button(my_w,text='Click Me to Agree',font=font1,bd=6,width=14,
 command=lambda:b2.config(text='I agree'),
 activebackground='red',activeforeground='yellow')
b2.grid(row=0,column=2,padx=5,pady=60)

my_w.mainloop()

Buttons Dynamic Buttons handling
Images used over button to create ON / Off switch
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer