PETRONODE

4.1. Making Basic Plot.

The following example demonstrates the basic concept of programmatic SlideComposer operation.

First, the control file is created, then the SlideComposer is launched with the control file, input and output folder and the silent key (/s). Finally the newly produced png file is launched into your system's default viewer.

#

# Example 09 - making a basic plot

#

import os

import subprocess

#

# location of Petronode install folder

#

cBatchProcessorFolder = "C:\\Program Files\\Petronode"

#

# create plot

#

def Create_Plot ( workfolder, output, cdl):

    Params = [os.path.join( cBatchProcessorFolder, "Petronode.SlideComposer.exe")]

    Params += [ os.path.join( workfolder, output + ".def")]

    Params += [ workfolder]

    Params += [ workfolder]

    Params += [ "/s"]

    print( "Creating control file " + Params[1])

    f = open (Params[1], "w")

    for l in cdl: f.write( l + "\n")

    f.close()

    print( "Starting Slide Composer: ")

    print( Params)

    subprocess.call( Params)

    print( "Image Processing Completed")

Name = input ( "What is your name? ")

lines = []

lines += ["#"]

lines += ["# Create test image"]

lines += ["#"]

lines += ["slide (Test, 300, 200, png)"]

lines += ["shape (10, 10, 280, 120, rectangle, 3.0, FF000000, FFAA0000)"]

lines += ["labelover ( 20, 20, 260, 30)"]

lines += ["\tText =Hello, " + Name + "!" ]

lines += ["\tFontSize = 12.0"]

Create_Plot( ".", "Example_09", lines)

os.startfile( "Test_image.png")

If you enter 'Mike' for the name, produced image will look like this:

Example_09