Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Show image, with options to resize it.

 #IMPORT SOME MODULE NEED pip install pillow  
#if not esists
import os, sys, Tkinter
from PIL import Image, ImageTk
#FIRST GLOBAL PARAM TO PATH
#USES Pictures folder of user that run script
PIC = os.path.expanduser('~')+"\Pictures"
#CALCULATE RESULT IS HERE
list_with_pic = []
old_label_image = None
#FUNCTION CLOSE PICTURE WHEN PUSH LEFT MOUSE BOTTON
def button_click_exit_mainloop (event):
"""FUNCTION CLOSE PICTURE WHEN PUSH LEFT MOUSE BOTTON"""
event.widget.quit() # this will cause mainloop to unblock.
#THIS SEARCH FOR PICTURES IN PIC FOLDER
#RETURN ABSOLUTE PATH
def search_picture(PATH):
"""THIS SEARCH FOR PICTURES IN PIC FOLDER / RETURN ABSOLUTE PATH"""
for root_p, dirname, filename in os.walk(PATH):
for file in filename:
if file.endswith(("jpg","png")):
yield os.path.join(root_p, file)
#RETURN RESULT SPARES MEMORY
def return_orig():
"""RETURN RESULT SPARES MEMORY"""
for result in search_picture(PIC):
yield result
#SHOW PICTURES USE TKINTER TO VISUALIZE
def show_pic():
"""SHOW PICTURES USE TKINTER TO VISUALIZE"""
len_of_pictures = [] #CALCULATE RESULT
for m in return_orig():
len_of_pictures.append(m)
print ""
#PRINT TOTAL LEN OF FOUND PICTURE'S
print "The total len of pictures is {}".format(len(len_of_pictures))
print ""
#ASK TO OPEN PICTURE FOR VIEW OR NOT, TKINTER CLOSE WHEN HIT N/n or somthing else
ask = raw_input("Do you want to open all image's : Y or N _\b" )
if ask == 'Y' or ask == 'y':
root = Tkinter.Tk()
root.bind("


This post first appeared on Linux Command's, please read the originial post: here

Share the post

Show image, with options to resize it.

×

Subscribe to Linux Command's

Get updates delivered right to your inbox!

Thank you for your subscription

×