Load or keep Setup parameters through Klayout script?

edited November 2018 in General

I am loading a design file with a python script (It is fine if the answer uses Ruby), and I would like to have a very steady opening view, no matter what the previous user did with the setup.
Is it possible to edit the viewer setup parameters and set them up to a given value?
The more important parameters I wish to be each opening the same are: backgroung color=black, do not show background decoration, and always untick ‘show layer without fill’
I could eventually find the function mw.current_view().set_config(name,value), but for this function I could not find anywhere a list of possible config names?
Also when I search with mw.current_view().get_config_names() is always an empty list,
Other possible turn around questions:

  • is it possible to save the setup into a file and load it at start ?
  • is it possible to lock the setup (read only file?) so there will not be no possibility for the user to edit it?

Thanks! :)

Comments

  • I actually found the answer of my own question from browsing through unrelated questions:

    there is a file in my own ~/.klayout or C:/user/klayout which is created with each opening of Klayout, the file name 'klayoutrc', this file includes all the parameter names and their current values.

    For instance this will set the background collor to black automatically: mw.current_view().set_config('background-color', '#000000')

    The function will not overwrite the default values (for instance the background would still be white in the Setup Menu) and therefore not modify the default local 'klayoutrc'

    When using Setup menu, the new value will be displayed and saved in 'klayoutrc' file,

    So basically the display priority for Config values are in order:
    1) last manually set through the set-up file
    2) config values set through set_config() function
    3) original value from the klayoutrc when starting Klayout

    I hope this helps the next user, don't hesitate to correct or add to my answer.

  • Hi jonathan,

    the LayoutView's "get_config_names" will only deliver the names of the configuration variables which have been set for this view only. Normally, you'll set configuration variables on the Application object (and get their names through Application#get_config_names). But you can configure views individually - i.e. when you want one view to have a different background than the others. If there are no special variables for a view, it's get_config_names list is empty.

    Nevertheless, as you have discovered the configuration file, that's the easier to sudy and to modify. If you want to use multiple pre-configured environments, you can switch between them using

    klayout -c ~/.klayout/myspecialconfiguration -t ...
    

    where "myspecialconfiguration" is a file with the same format than "klayoutrc", but specific settings. "-t" will stop klayout updating this file on exit which helps preserving these special settings.

    Matthias

  • Hello Mathias: Thanks a lot! I now have all to set up the configuration up to my wishes. :)

Sign In or Register to comment.