Business Intelligence Tools / Developers Corner

IronPython to Turn Panels On & Off

  • Are you building projects for users who aren’t familiar with Spotfire’s concept of panels?
  • Would you like to be able to turn panels on and off with the click of a button?
  • Do you want to learn a little bit more about IronPython?

This week, I am sharing a bit of code that I’ve used for years in almost every project I build.  It is easy to use IronPython to turn panels on and off. It is especially useful when…

  1. Building projects for people who aren’t familiar with Spotfire controls
  2. Building for the web player
  3. Space is tight and I want to be able to quickly and easily turn panels on and off

You might be wondering why this code would be useful for the web player.  Well, web player users don’t have the ability to toggle all panels on and off.  As shown below, web player users only have access to the Filter Panel and the Bookmarks Panel.

Code Screenshot

Here is the code in Spotfire.  I always take a screenshot because the copy and paste sometimes corrupts spacing.

Code Snippet

And here is a code snippet that you can copy and paste.  Adjust indents accordingly.


if (Document.ActivePageReference.FilterPanel.Visible == False):

Document.ActivePageReference.FilterPanel.Visible = True


Document.ActivePageReference.FilterPanel.Visible = False

Steps to Implement Code

  1. Add a Text Area
  2. Right-click, select Edit HTML
  3. Click the insert Action Control button
  4. Type in a name for the button, such as “Show Hide Details on Demand”
  5. Click the Script button
  6. Name the script.
  7. Copy and paste the script.
  8. Click Run to test. (No paramters required).

And you’re done!

Modifying for Different Panels

The code snipppet shown above will work for the Details on Demand Panel.  To modify it for the Filter Panel, substitute “DetailsOnDemand” for “Filter”.  To modify it for the Data Panel, you will need different code.  See below.

import Spotfire.Dxp.Application.PanelCollection
import Spotfire.Dxp.Application.PanelTypeIdentifiers
from Spotfire.Dxp.Application import Panel
from Spotfire.Dxp.Application.Layout import PanelState as ps

for panel in Document.ActivePageReference.Panels:
if (panel.TypeId.DisplayName == “Data”):
if (panel.Visible == True):
elif (panel.Visible == False):
panel.PanelState = ps.Docked
panel.Visible= True

If you want to explore other panels, check out the API reference here (note, this is the 7.14 reference).

If You Liked This Try

Spotfire Version

Content created with Spotfire version 7.12.

Leave a Reply

Your email address will not be published. Required fields are marked *