create a standalone layout, then assign it to a MainWindow & Current View

Hi Matthias,

I would like to write a Python script which generates the layout in standalone mode (https://www.klayout.de/doc-qt5/programming/database_api.html). Then I would like to create a main window and layout view that is the same as the previously created object.

So rather than:

layout = main_window.create_layout(1).layout

I would like to have something like this:

main_window.assign_layout = layout

I am hoping to have this run in the Application mode. And I don't want to "save" and "load" the layout, which can presently be done.

thank you
Lukas

Comments

  • I found a way:

    ly.assign(layout)
    

    we can delete this question.

  • Very good :)

    We can leave the question open, because there is another way I would like to contribute:

    mw = pya.MainWindow.instance()
    mw.create_view()
    mw.current_view().show_layout(ly, True)   # True: add to view
    

    The advantage in my point of view is that the Layout object is not copied. Instead, the ownership of that object is transferred to the view. So any Cell references will stay valid for example.

    Matthias

Sign In or Register to comment.