Getting layout in headless mode

Hi, Matthias!

I had script that does some layout processing in batch mode. It's run fine in hidden views mode: klayout <layout> -z -r <script>, but failed in headless mode: klayout <layout> -zz -r <script>.

In both cases layout is accessed trough:

cell_view =
layout = cell_view.layout()
layout post-processing

I added debug prints for cell_view and layout and script returns None for layout in headless mode.

Layout class documentation is too brief for headless mode, so it'll be good idea to expand it to use cases similar to above. If headless mode doesn't not create GUI objects, may be Layout class should provide access to collection of opened layouts instead of CellView?


  • @EugeneZelenko In headless mode there is no user interface, hence there are not UI-related objects like MainWindow and LayoutView.

    On Linux I solve the problem by running klayout in a virtual XServer environment using

    xvfb-run klayout -z ...

    For the future I am preparing a Qt-less release which also features a stripped-down version of LayoutView for Python modules. This is not the same as headless mode, but this is a way to batch layout view features without needing a display or even Qt. See here for details:


  • Hi, Matthias!

    Thank you for explanations!

Sign In or Register to comment.