[Paraview] Remove opengl window while saving images from Python script

Laurent Vanboquestal laurent.vanboquestal at gmail.com
Mon Jun 28 04:29:50 EDT 2010


Hello,

I would like to generate png images from a pvd file using python.
However, when I do this, several windows are opened and closed quickly ...
(which is really annoying for my application),

Is anybody know a way to get rid of these windows ???

I am using paraview 3.8

I tried already the : view.UseOffscreenRenderingForScreenshots = False
parameter but it doesn't really help!

Here is my python code:

Best Regards,

Laurent

def generatePNGFileFromParaview(inFile, outFile):
    # Instantiate a Paraview VTU reader
    reader = OpenDataFile(inFile)
    # Parameter stored in ini file
    min_val = 300
    max_val = 1922.35
    ScalarBarTitle = "Temperature"
    ColorArrayName = 't'
    PictureTitle = "Temperature"
    Magnification=1  # PNG Zoom factor

    lt = MakeBlueToRedLT(max_val, min_val)

    bar = CreateScalarBar(LookupTable=lt, Title=ScalarBarTitle)
    bar.LabelColor = [0.0, 0.0, 0.0]
    bar.TitleColor = [0.0, 0.0, 0.0]
    bar.LabelFontSize = 12
    bar.AspectRatio   = 15.0
    bar.AutomaticLabelFormat = 0

    Show()
    Render()

    view = GetActiveView()
    view.Background = [1,1,1]  # White

    view.ViewSize = [800, 600] # Size in pixel of the output

    # I tried to set this value to True or False, but the opengl
windows are still opened
    view.UseOffscreenRenderingForScreenshots = False


    ResetCamera(view)

    dp = GetDisplayProperties()
    dp.ColorArrayName = ColorArrayName

    rep = GetRepresentation()
    rep.LookupTable = lt

    view.Representations.append(bar)

    # Add text for load
    text = Text()
    text.Text = PictureTitle

    repr = Show(text)
    repr.Color    = [0,0,0]
    repr.FontSize = 12

    Render()
    WriteImage('stage1.png', Magnification=2)

    Delete(rep)
    Delete(view)
    Delete(reader)


More information about the ParaView mailing list