Coders Packet

Animated Face Gesture using Tkinter

By Piyush Kumar Chaudhari

Changing pet face gestures by detecting of the cursor the animated face created here will change the expressions.

thise Pet Face Gesture using Tkinter module in Python is a basic application of GUI programming but it involves lots of concepts. By just the movement of the cursor, the animated face created here will change the expressions. When you take the cursor on the face it will create a cheeky and happy face, double-clicking on the face will create a toggling eyes expression and when we leave the face area for few seconds it will create a sad face.
Below are the steps required to create this project:
1) Import Tkinter - a standard Python Interface to the Tk GUI Toolkit. It provides a fast and easy way to create GUI applications.
2) For drawing a pet, create a canvas, and assign the height, width, and colour of your choice.
3) Create the body using the Canvas widget of the pet and assign coordinates, colour, and shape i.e oval, rectangle, polygon, etc whichever you want according to design.
                body = c.create_oval(35,45,365,350,outline=c.body_color,  fill=c.body_color)
4) Create a mouth, cheeks, tongue, and to hide and show the expression, set their states to HIDDEN or NORMAL.
5) Create events i.e cheeky, sad, and happy, and use the bind method for binding mouse buttons with Tkinter frame.
6) The only function that will work continuously is the blinking of the eyes and create a sad face after every 5 seconds.
7) Run the program and click on the window to see the face gestures.
Here are the output figures of the project

Download Complete Code


No comments yet