Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

tkinter hover button

#Here is a sample code for tkinter animation and hover
from tkinter import *

app = Tk()
app.geometry("300x250")
app.configure(bg="#141414")
app.title("Hover GUI")


def bttn(x,y,text,bcolor,fcolor, cmd):

    def on_enter(e):
        mybutton['background']= fcolor
        mybutton['foreground']= bcolor
    
    def on_leave(e):
        mybutton['background']= fcolor
        mybutton['foreground']= bcolor
    
    mybutton=Button(app, width=42, height=2, text=text,
                         fg=fcolor, 
                         bg = bcolor,
                         border=0,
                         activebackground=bcolor,
                         activeforeground=fcolor,
                         command=cmd)

    mybutton.bind("<Enter>", on_enter)
    mybutton.bind("<Leave>", on_leave)
    mybutton.place(x=x,y=y)
def cmd():
    print('You clicked A C E R')
def cmd1():
    print('You clicked A C E R')
def cmd2():
    print('You clicked A C E R')
def cmd3():
    print('You clicked A C E R')
bttn(22,0,"A C E R", "#ffcc66", "#141414", cmd)
bttn(22,37,"H A R D",  "lime","#ffcc66", cmd1)
bttn(22,74," E A SY",  "red","#ffcc66", cmd2)
bttn(22,148,"A S I A N", "blue","#ffcc66", cmd3)
app.mainloop()
Comment

PREVIOUS NEXT
Code Example
Python :: discord.py how to give a user a role 
Python :: save strings with numpy savetext 
Python :: how to add special token to bert tokenizer 
Python :: how to Take Matrix input from user in Python 
Python :: pandas read_csv multiple separator 
Python :: pyqt5 pylatex 
Python :: pandas scatter plot with different colors 
Python :: display entire row pandas 
Python :: get the system boot time in python 
Python :: You did not provide the "FLASK_APP" environment variable 
Python :: how to change the column order in pandas dataframe 
Python :: python gtts 
Python :: python get object attribute by string 
Python :: python define 2d table 
Python :: python temporary files 
Python :: python blowfish 
Python :: values of unique from dataframe with count 
Python :: pygame keys pressed 
Python :: while loop countdown python 
Python :: django all urls 
Python :: check if number in range 
Python :: tqdm parallel 
Python :: python version check 
Python :: or statement django template 
Python :: bisect_left in python 
Python :: how to delete records in pandas before a certain date 
Python :: get max value column pandas 
Python :: timed loop python 
Python :: python logging to file 
Python :: python dedent 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =