
The relevance is a little Microsoft bashing which I think is always useful in the context of education, and some "why learn to program" from a personal frame of reference. The motive is really just some show-and-tell. Trying to finalize a website for a PyGeo release I had decided that I would rather show some sequences of Povray rendering of PyGeo animations as sequence of stills than as an animated gif. Google on "html slideshow" and find that a "HTML Slide Show Wizard" is among the WindowsXP "powertoys" at http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx The wizard is just that - and one lives with its output - backgrounds, arrow placements, etc.. And what it is doing is so simplistic that it is quite funny that it would be among the "powertoys". But Microsoft counts on a certain kind of audience for its wizardry. Attached is a small Python script with more functionality than the XP powertoy. Sample of slideshow is at: http://pygeo.sourceforge.net/slideshows/multiply_html/1.html Whether the slideshow idea works for this purpose being another matter. Art . import os import string import glob import shutil #location of images, relative to current directory currentimages='multiply' #html output directory, absolute path htmldir = 'c:\\PyGeoSite\\slideshows\\multiply_html' #images destination directory relative to html directory imagedest = 'images' #images extensions imageext = 'png' #background color background = '#FFFFFF' #arrow image names - ordered "<" (previous) and ">" (next) arrows=["prev.gif","next.gif"] #location of arrow images directory relative to current directory arrowsource='images' try: os.mkdir(htmldir) except OSError: pass try: os.mkdir(os.path.join(htmldir,imagedest)) except OSError: pass imagepath=os.path.join(htmldir,imagedest) arrowprev=imagedest + "/" + arrows[0] arrownext=imagedest + "/" + arrows[1] imagefiles = glob.glob(os.path.join(currentimages,"*.%s" %imageext)) totimages = len(imagefiles) i=1 for file in imagefiles: if i == 1: prev = totimages else: prev= i-1 if i == totimages: next = 1 else: next = i + 1 filename=string.split(file,os.sep)[-1] source = imagedest + "/" + filename shutil.copy(file,imagepath) html = """ <html> <body bgcolor="%s"> <br> <br> <center> <img src="%s"> </center> <br> <center> <a href="%i.html"><img border=0 align=center src="%s"></a> <a href="%i.html"><img border=0 align=center src="%s"></a> </center> </body> </html> """ %(background,source,prev,arrowprev,next,arrownext) f=open(os.path.join(htmldir,str(i)+".html"),'w') f.write(html) f.close() i+=1 for arrow in arrows: shutil.copy(os.path.join(arrowsource,arrow),imagepath)
participants (1)
-
Arthur