def FadeText( iId, iFadeTime, bIn, aColor ): "fade in or out a given text" if iFadeTime<>0: iStep = 10 aHsv = mindiapy.RgbToHsv( aColor ); s = "%d %d %d" % (aHsv.iHue, aHsv.iSaturation, aHsv.iValue) mindiapy.PrintLn( s ) for i in range(0,iFadeTime,iStep): dDelta = 255.0 / (iFadeTime / iStep) iGray = ((i/iStep)*dDelta)/255.0 if bIn == 0: iGray = (1.0 - iGray) aHsv.iSaturation = iGray*255 aColor = mindiapy.HsvToRgb( aHsv ) aWin.SetTextColor( iId, iGray*aColor.iRed, iGray*aColor.iGreen, iGray*aColor.iBlue ) #s = "%f %d %d %d" % (iGray, aHsv.iHue, aHsv.iSaturation, aHsv.iValue) #mindiapy.PrintLn( s ) else: aHsv.iSaturation = iGray*255 aColor = mindiapy.HsvToRgb( aHsv ) aWin.SetTextColor( iId, iGray*aColor.iRed, iGray*aColor.iGreen, iGray*aColor.iBlue ) #s = "%d %f %f %f" % (i, iFadeTime, dDelta, iGray) #s = "%f %d %d %d" % (iGray, iGray*aColor.iRed, iGray*aColor.iGreen, iGray*aColor.iBlue) #mindiapy.PrintLn( s ) mindiapy.SleepMS( iStep ) return iId
def CopyAllSounds(sNewSoundPath): sNewSoundPath = os.path.normpath(sNewSoundPath) if not os.access(sNewSoundPath, os.F_OK): os.mkdir(sNewSoundPath) for i in range(0, aPres.GetSoundFileCount()): sSoundFile = os.path.normpath(aPres.GetSoundFileNameAt(i)) (h, t) = os.path.split(sSoundFile) sNewSoundFile = sNewSoundPath + os.sep + t s = "%d %s %s" % (i, sSoundFile, sNewSoundFile) shutil.copyfile(sSoundFile, sNewSoundFile) aPres.SetSoundFileNameAt(i, sNewSoundFile) mindiapy.PrintLn(s)
def CopyAllImages(sNewImagePath): sNewImagePath = os.path.normpath(sNewImagePath) if not os.access(sNewImagePath, os.F_OK): os.mkdir(sNewImagePath) for i in range(0, aPres.GetDiaCount()): aDia = aPres.GetDia(i) sName = os.path.normpath(aDia.GetImageFile()) (h, t) = os.path.split(sName) sNewName = sNewImagePath + os.sep + t s = "%d %s %s %s %s %s" % (i, sName, h, t, sNewName, os.getcwd()) shutil.copyfile(sName, sNewName) aDia.SetImageFile(sNewName) mindiapy.PrintLn(s)
# Import presentation data from a csv-file (import.csv) import mindiapy aObj = mindiapy.GetDiaPresentation() sFileName = "import.csv" #mindiapy.PrintLn( sFileName ) try: aFile = open( sFileName, "r" ) except IOError: mindiapy.PrintLn( "Error: File %s not found !" % sFileName ) else: # read all lines of the file aLines = aFile.readlines() # fill data in presentation for s in aLines: aItem = aObj.AddNewDia() #mindiapy.PrintLn( s ) # process the single line aSingleLine = s.split( "," ) if len( aSingleLine ) > 1: aItem.SetId( aSingleLine[1] ) if len( aSingleLine ) > 2: aItem.SetDissolveTime( float( aSingleLine[2] ) ) if len( aSingleLine ) > 3: aItem.SetShowTime( float( aSingleLine[3] ) )
# show all loaded modules (in output window) import sys import mindiapy aList = sys.path aList = sys.modules for s in aList: mindiapy.PrintLn("s=%s" % s)
# where to copy on the PC sTargetOffset = "e:\\test\\" # "g:\\" #sTargetOffset = "g:\\" # location of the files on the Zaurus sLocalOffset = "/mnt/cf/" aPres = mindiapy.GetDiaPresentation() # update the path to the sound files # copy the sound files iCount = aPres.GetSoundFileCount() for i in range(iCount): sSource = aPres.GetSoundFileNameAt(i) (sPath, sName) = os.path.split(sSource) sTarget = sTargetOffset + sName sLocalTarget = sLocalOffset + sName shutil.copy(sSource, sTarget) aPres.SetSoundFileNameAt(i, sLocalTarget) mindiapy.PrintLn("copied " + sSource + " --> " + sTarget + " as " + sLocalTarget) # and than save the presenation sFullName = aPres.GetDocName() (sPath, sName) = os.path.split(aPres.GetDocName()) aPres.SavePresentationAs(sTargetOffset + sName) mindiapy.PrintLn("saved presentation " + sPath + sName + " as " + aPres.GetDocName()) aPres.LoadPresentation(sFullName) mindiapy.PrintLn("loading original presentation " + sFullName + " again.")
# Load a presentation successor file import mindiapy aObj = mindiapy.GetDiaPresentation() iRet = mindiapy.DoMessageBox("Really load a successor file ?", "Question") if iRet == 0: iRet = aObj.LoadPresentation("successor.dia", 1) else: mindiapy.DoMessageBox("Successor file NOT loaded !", "Warning") s = "ret=%d" % iRet mindiapy.PrintLn(s)
# set new show time for all dias import mindiapy mindiapy.PrintLn("set new show time for all slides") aObj = mindiapy.GetDiaPresentation() #s = "count=%d" % aObj.GetDiaCount() #mindiapy.PrintLn( s ) for i in range(0, aObj.GetDiaCount()): aItem = aObj.GetDia(i) s = "dia %d id=%s dissolve=%f show=%f" % ( i, aItem.GetId(), aItem.GetDissolveTime(), aItem.GetShowTime()) aItem.SetShowTime(aItem.GetShowTime() * 1.125) #sId = "id%d" % (i+1) #aItem.SetId( sId ) mindiapy.PrintLn(s) aItem = aObj.GetDia(0) # test dia if aItem: mindiapy.PrintLn("then") else: mindiapy.PrintLn("else") s = "dia %d dissolve=%f show=%f" % (0, aItem.GetDissolveTime(), aItem.GetShowTime()) mindiapy.PrintLn(s) #bla
# test for text output on the play info dialog import mindiapy import time aPres = mindiapy.GetDiaPresentation() aWin = aPres.GetOutputWindow() x = aWin.GetWidth() y = aWin.GetHeight() aWin.SetFont("Times") aWin.SetColor(250, 255, 0) aWin.SetFontSize(28, 0, 0) i = aWin.SetTextXY(200, 120, "Hallo Welt") s = "%d %d i=%d" % (x, y, i) mindiapy.PrintLn("ok s=" + s) for ii in range(0, 25): aWin.MoveText(i, ii, ii) time.sleep(0.1)
# Simple python test program (print message in output-window) import mindiapy mindiapy.PrintLn("hallo Pyhton !") aObj = mindiapy.GetDiaPresentation() s = "The count of slides in presentation is %d" % aObj.GetDiaCount() mindiapy.PrintLn(s) # # $Source: /Users/min/Documents/home/cvsroot/mindia/scripts/simple.py,v $ # # $Revision: 1.2 $ # # $Log: not supported by cvs2svn $ #