It looks like you're new here. If you want to get involved, click one of these buttons!
Hi, Matthias!
I'd like to change default LayoutView
titles in tab control in edit window to remove top cell name.
I tried next code that inserted into configuration file (read with -rm
command-line option):
def remove_top_level_cell_name_from_view_title(index): def on_file_open(view): title = view.title print('Original title: {0}'.format(view.title)) opening_bracket_position = title.find(' [') if (opening_bracket_position != -1): view.title = title[:opening_bracket_position] print('New title: {0}'.format(view.title)) view = pya.Application.instance().main_window().view(index) view.on_file_open = lambda __view=view: on_file_open(__view) main_window.on_view_created = remove_top_level_cell_name_from_view_title
Debug output is intended, but nevertheless titles in GUI were not affected. I tried 0.26.4 and 0.26.10.
Comments
Hi Eugene,
The problem is that "on_file_open" isn't called on "on_view_created" because that already happened. So you have to explicitly call it in the "on_file_open" event handler.
Still registering this callback makes sense as this is called when you load another layout into the view.
One small remark: I'm no quite sure if the inner "def" isn't executed always when the event is executed. This should not create an issue, but maybe it's more efficient (if performance matters) to define the inner function outside.
Anyway here is my working, modified code:
Kind regards,
Matthias
Hi, Matthias!
Thank you for help! I'll try your solution later.
Hi, Matthias!
I tried your code in command line situation:
klayout -rm <configuration> -u <session>
and it doesn't work :-(. First call toon_file_open
show empty title, callback one - doesn't affect tabs.@EugeneZelenko I just tried that, but it works at least for my case:
I put the script above in a file called "init.py" and prepared a session file which opens a single layout and called that "session.lys".
Now I run klayout like this:
and as expected the tab titles show the file names without cell name
I tested that on 0.26.9 on Ubuntu 20.
Matthias
Hi, Matthias!
Weird, but it didn't work for me I tried standard 0.26.10 and our own 0.26.4 builds on Ubuntu 18 with sessions with one and for layouts.
Could logging help to drill into source of problem?
Hmm .. maybe there is some other script interfering?
Please try setting $KLAYOUT_HOME to some non-existing path. This will strip all macros and configuration settings by using a fresh installation. If the problem still persists, maybe some print's may help to trace which calls are made and which aren't.
Matthias
Hi, Matthias!
Changing
$KLAYOUT_HOME
to non-existing path didn't help. I'll try to add logging to KLayout to trace title.Hi, Matthias!
Below is log of my KLayout build with added output (method name, stage + LayputView title) from layMainWindow methods. Somehow title is reverted back to original form after change in Python. I'll try to add more logging to catch
update_tab_title
calls.Last
update_tab_title
was caused byview->set_title
call fromSession::restore
with empty string argument.So proper solution would be to write
title
tags in session file instead of building Python code :-)Hi, Matthias!
Is it possible to introduce
title
tocellview
too, so it'll override default one in cases when several files opened in same view?Hi Eugene,
thanks for the debugging. It's strange I don't see this in my case. I'll need to check.
The title tags in session files are actually worth considering. That makes sense. I have created a ticket for this: https://github.com/KLayout/klayout/issues/737
Matthias
@EugeneZelenko
I just discovered that the titles are already included in the session files:
maybe this helps?
Matthias
Hi, Matthias!
Yes, I discovered this too during debugging :-)
But I'd like to still update file name on tab bar when user switches cellviews (but without top cell name, added by default), so this is reason why I asked for
cellview
enhancement.Hi Eugene,
I see the point.
It's somewhat redundant as then there is a layoutview title and a cellview title. I think the layout view title (if set) should still have priority to maintain backward compatibility.
I think there already is something like a cell view title, but it's not accessible. It should be a low hanging fruit though. I have created a ticket for this: https://github.com/KLayout/klayout/issues/745
Matthias
Hi, Matthias!
Sure, view title should have priority over cell view title. Implementation for my application that I had in mind followed this rule: set view title for view with one file and cell view titles for view with several files.