I have finally got my program finished and going. Im now looking to make it look a bit better. While it is processing it shows and empty tk window. How does one go about putting something in here? I'd just like my users to be reassured it is actually working and not crashed. Ideally a progress bar or similar but anything from text listing the current file, a count of files done or just a spinny loading icon would do. Here is the code if anyone is interested.
import Image, os, tkFileDialog, tkMessageBox
def watermark(im, mark, mark2):
if im.mode != 'RGBA':
im = im.convert('RGBA')
wd = float(im.size[0])
ht = float(im.size[1])
if wd > ht:
basewidth = 720
wpercent = (basewidth/float(im.size[0]))
hsize = int((float(im.size[1])*float(wpercent)))
im = im.resize((basewidth,hsize))
else:
baseht = 720
wpercent = (baseht/float(im.size[1]))
wsize = int((float(im.size[0])*float(wpercent)))
im = im.resize((wsize,baseht))
layer = Image.new('RGBA', im.size, (0,0,0,0))
layer.paste(mark, ((im.size[0]-mark.size[0]) , (im.size[1] - mark.size[1]) ))
layer.paste(mark2, (0,0))
return Image.composite(layer, im, layer)
def run():
tkMessageBox.showinfo("Select Folder", "Specify Image Folder")
p = tkFileDialog.askdirectory()
tkMessageBox.showinfo("First Logo", "Select first .png logo")
b = tkFileDialog.askopenfile()
mark = Image.open(b)
tkMessageBox.showinfo("Second Logo", "Select second .png logo")
c = tkFileDialog.askopenfile()
mark2 = Image.open(c)
os.chdir(p)
x = 0
count = 0
while (count < 1):
for i in os.listdir(os.getcwd()):
count = count + 1
im = Image.open(i)
watermark(im, mark, mark2).save('pro_'+ i , "JPEG", quality=95)
if __name__ == '__main__':
run()
Many thanks,
Rich