1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 <2025> | Index | 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 <2025> |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: [CSS/Phoebus] Adding widgets as children to other widgets, from Python |
From: | "Gonzalez, Jose Carlos via Tech-talk" <tech-talk at aps.anl.gov> |
To: | "Kasemir, Kay" <kasemirk at ornl.gov>, "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov> |
Date: | Thu, 13 Mar 2025 12:28:28 +0000 |
Hi!
I was trying to use Navigator Tabs, but I could not find my way getting the "children() collection to add a new child, so I changed to Tabs (that, in fact, in my case it could really have more sense), and it worked great.
Thanks!
J C From: Kasemir, Kay <kasemirk at ornl.gov>
Sent: 11 March 2025 15:14:11 To: Gonzalez, Jose Carlos; tech-talk at aps.anl.gov Subject: Re: [CSS/Phoebus] Adding widgets as children to other widgets, from Python 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. > .. 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) |