On 25.11.2016 18:25, Richard Heck wrote:
On 11/25/2016 04:30 AM, racoon wrote:
Does anyone happen to know how to get a toolbar gui name, e.g.
"Standard", from a toolbar name, e.g. "standard"?
I tried `ToolbarInfo(name).gui_name` but it just gives an empty string.
The problem is that "ToolbarInfo(name)" just constructs a new instance,
with no information other than the name you gave it.
Probably it can be done somehow with `Toolbars::info`? But I don't
know how.
I don't know much about the toolbars, so this may or may not work. Here
"name" is the thing we are looking for.
docstring gui_name;
# Get the toolbars
Toolbars const & bars = theApp().toolbars();
# Find the one we want
Toolbars::Infos::const_iterator it = bars.begin();
Toolbars::Infos::const_iterator en = bars.end();
for (; it != en; ++it) {
if (it->name == name) {
gui_name = it->gui_name;
break;
}
}
# now gui_name should have the right string, unless
# we didn't find the name, in which case it is still empty
I guess there's some fancy new way to do these iterations, but I can't
remember what it is.
Thanks for the helpful explanations. And it works too.
Actually, I have seen a similar iteration elsewhere but there it was
actually used to do something with every toolbar, so thought that there
is probably a simpler way to get the info for just one bar.
Daniel