Changing main window title

Hi, Matthias!

Is there are way to change main window title via environment variable/command-line option/scripting (adding arbitrary suffix to KLayout <version>)? Our application may launch multiple instances of KLayout, so it'll be easier to differentiate them. Currently tab title is added, but in our case all tabs in session are created by same code, so duplicating description in each tab would be overkill as well as complicate switching between multiple tabs when scrolling would be necessary.

Comments

  • Hi Eugene,

    basically you can change the window title this way:

    pya.MainWindow.instance().windowTitle = "New title"
    

    This works because pya.MainWindow inherits QMainWindow. However, the title is reset when KLayout loads a new file or the tab is changed. So that's not a permanent solution.

    Best regards,

    Matthias

  • Hi, Matthias!

    Thank you for explanations! Looks like doable after some work :-)

  • On other thought it'll be good idea to specify such string in session, so it could be used after KLayout re-launch.

  • Hi, Matthias!

    I embedded necessary data to layout's user properties and then change title in MainWindow.on_current_view_changed and CellView.on_active_cellview_changed handlers by calling same function. This works fine in former case, but not in later. Looks like title set in CellView.on_active_cellview_changed is overridden by standard one after notification call.

  • edited June 2021

    Hi, Matthias!

    I dug into code and found that MainWindow::current_view_changed generate event after title update, but LayoutView::active_cellview_changed emit title_changed event for empty title after active_cellview_changed_event.

    By the word, LayoutView::active_cellview_changed_with_index_event seems to be unused.

  • Hi Eugene,

    yes, the title patch is just temporary. It's using the underlying Qt object directly.

    I don't think it's basically possible to capture all cases when the title is overwritten, so either you install a timer that periodically resets the title (ugly) or a custom main window title is introduced as a native feature.

    Matthias

Sign In or Register to comment.