How To Create Image Viewer Using Python, Tkinter And PIL/pillow
Posted by
Suraj Singh
on February 19, 2017 ·
15 mins read
hii readers,
Today's Tutorial is about how to create image viewer using python tkinter and pil/pillow image library or you can say how to use pil/pillow with python Tkinter canvas widget.
so, let's start but first if you are new visitor then don't forget to check our index page because there you will find really very interesting stuff.
hmm,
In Today's Topic we will use python PIL/pillow Image Library. because with this module we can do many interesting works with images. hence, for today's topic first install pil/pillow in you pc.
Here, For This Purpose You Need To Create Four Scripts.
1. Config.py (For All Configurations)
2. Path.py (For Path Related Functions)
3. GUI.py (For Graphic User InterFace Functions)
4. ImageHandle.py (For Handling Image Functions)
Here, I am Dividing All Works In 4 Scripts because with this division we can do our work more easily.
let me explain what we will do with this four script.
here, we will use config.py as all configurations settings file. because with this file we can do change easily.
Path.py is for handling Image Directory Path And Image Path.
GUI.py is for handling Gui Control Functions And Widget Looks. And at the end, ImageHandle.py this script is for handling image functions like image size, etc
so, let's see practical demo codes.
(Note : Paste all Scipts in same folder)
Here, I am Sharing My Demo Codes But If You Want More Better Example Then, You Can Modify these codes yourself or Download This Script From My GitHub repository (link given at the end of these codes ).
# ---------------- READ ME --------------------------------------------- # This Script is Created Only For Practise And Educational Purpose Only # This Script Is Created For http://www.bitforestinfo.com # This Script is Written By __author__='''
###################################################### By ######################################################
#!/usr/bin/python # ---------------- READ ME --------------------------------------------- # This Script is Created Only For Practise And Educational Purpose Only # This Script Is Created For http://www.bitforestinfo.com # This Script is Written By __author__='''
###################################################### By ######################################################
###################################################### ''' import os from config import *
def get_list(): Images=[] for ImageP in ImageDir: for i in os.listdir(ImageP): Image = os.path.join(ImageP,i) ext = Image.split('.')[::-1][0].upper() if ext in Extension: Images.append(Image) return Images
# ---------------- READ ME --------------------------------------------- # This Script is Created Only For Practise And Educational Purpose Only # This Script Is Created For http://www.bitforestinfo.com # This Script is Written By __author__='''
###################################################### By ######################################################
# ---------------- READ ME --------------------------------------------- # This Script is Created Only For Practise And Educational Purpose Only # This Script Is Created For http://www.bitforestinfo.com # This Script is Written By __author__='''
###################################################### By ######################################################