Best try to avoid scripts in the display. Scripts for the display builder desktop won’t function in the web runtime, and when you eventually transition to whatever is the hot display tool in 5 years, you’ll
have to re-do that.
Maybe you can simply use the Navigation Tabs widget as is?
Or use scripts to generate the XML for the display files offline, not running inside the display?
Otherwise, if you’re ready to read the examples, dig into the API (TabsWidget, TabItemProperty, ChildrenProperty, ..), and prepare to update your scripts as the API might change.
> How can I get the page handlers for the .. Navigator Tabs widget
See ‘Change Tabs’ button in the nav tabs example. It has a script which adds/removes tabs.
https://github.com/ControlSystemStudio/phoebus/blob/0ae9b167491f6f33bea46f998e58988b3e20e34d/app/display/model/src/main/resources/examples/structure_navtabs.bob#L135
> .. a child of one of those <tabs>
# Example script for "Tabs" widget that adds content to a tab
from org.csstudio.display.builder.model import WidgetFactory
# Add widget to existing tab
w = WidgetFactory.getInstance().getWidgetDescriptor("label").createWidget()
w.setPropertyValue("x", 20)
w.setPropertyValue("y", 10)
w.setPropertyValue("text", "Example")
# Add to 2nd tab (counting from zero)
tab = widget.propTabs().getElement(1)
tab.children().addChild(-1, w)
# Select the active tab
widget.setPropertyValue('active_tab', 1)
From:
Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of Gonzalez, Jose Carlos via Tech-talk <tech-talk at aps.anl.gov>
Date: Tuesday, March 11, 2025 at 6:45 AM
To: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: [EXTERNAL] [CSS/Phoebus] Adding widgets as children to other widgets, from Python
Hi, I'm trying to use scripting to populate a CSStudio/Phoebus panel/display with a set of replica of a template panel, which shows information from a single monitored
entity. In total, there would be N1 copies of that template in the panel
Hi,
I'm trying to use scripting to populate a CSStudio/Phoebus panel/display with a set of replica of a template panel, which shows information from a single monitored entity. In total, there would be
N1 copies of that template in the panel (distributed in rows and columns). I'm following pretty much the example provided in the template sample panel.
Now, in fact I don't have 1 single set of entities, but 3 of them. So, I have two possibilitites:
a) I can create 3 similar panels, each of them showing one of these 3 sets, or
b) I can (my preferred solution, if possible) I can create 1 single panel with a Tabs or Navigator Tabs widget, with 3 pages, and show in each of them one of those 3 sets.
My only question is: how can I, from a Python script, make that the new template panel that I'm replicating is a child of one of those pages (instead of being a child of the display/panel itself).
In the later case, I use:
display = widget.getDisplayModel()
to get the display handler, and then
for i in range(...):
. . .
instance = createInstance(...)
display.runtimeChildren().addChild(instance)
to add each single instance ans a child of the display.
How can I get the page handlers for the Tabs or Navigator Tabs widget, instead?
Thanks in advance,
J C
--
Jose Carlos Gonzalez
Max-Planck-Institut für Plasmaphysik
Experiment-IT - Tokamak Scenario Development - L6/18
Boltzmannstr. 2,
D-85748 Garching bei München
Phone
+49 89 3299-1698
jose.carlos.gonzalez at ipp.mpg.de