[Paraview] Suppress X display while saving images from Python script

M. Nawijn nawijn at gmail.com
Fri Jul 24 04:14:34 EDT 2009


Hello,

I have Python script that generates PNG images from a Paraview
session. This in essence works very well. The one problem that I have
is that an OpenGL window is created whenever I save the image. When
you do this in a loop, it becomes a little annoying, since the window
(at least on my Fedora box) automatically gets focus.

Is there a way to generate the PNG images without popping up a window?
Is it hardware/driver/platform dependent? I am using Paraview 3.7
(CVS) and Fedora FC11, NVIDIA proprietary drivers.

For completeness and maybe for the interest of other people, I copied
the body of my PNG image generation procedure below. Notice the
explicit deletions at the end of the script. These are mandatory in my
case since I update for example the colour legend in each step of the
loop.

        # Instantiate a Paraview VTU reader
        reader = XMLUnstructuredGridReader(FileName=model.filename)

        lt = MakeBlueToRedLT(max_val, min_val)

        bar = CreateScalarBar(LookupTable=lt, Title=key)
        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]
        ResetCamera(view)

        dp = GetDisplayProperties()
        dp.ColorArrayName = 'W'

        rep = GetRepresentation()
        rep.LookupTable = lt

        view.Representations.append(bar)

        # Add text for load
        text = Text()
        text.Text = 'Load %4.1f' % model.load

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

        Render()

        WriteImage('stage-%d.png' % model.stage, Magnification=2)

        repr.FontSize = 14
        bar.LabelFontSize = 14

        UpdatePipeline()

        Render()
        WriteImage('stagethumb-%d.png' % model.stage, Magnification=0.75)

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


Kind regards,


Marco


More information about the ParaView mailing list