Tip of the Week

Adding Instructional Help Files into your Analysis Files in TIBCO Spotfire Professional

It is very important to add instructions in your Analysis files in order to explain to others how they should use it.  This can be done in a variety of ways. The most direct way is to add Text Areas that contain the necessary information.  The downside of this approach is it takes up a lot of real estate in the analysis file.  Another viable approach would be to add a button which will launch the instructions in a popup dialog.  We will first show you how to do this in TIBCO Spotfire Professional, and then in a future post we will show you how to do this so it works in TIBCO Spotfire Web Player.

Once we are done, you will have a small Text Area with just one button. When the user clicks on that button, a window will open above Spotfire with the instructions. This can be developed to be one instruction set for the entire analysis or one for each page. See the image below for what the final version could look like.

 



To start with, we need to figure out where the instructions will be stored. Given this is meant for people only using Spotfire Professional and not the Spotfire Web Player (we will discuss how to do this for a Web Player file in an upcoming post), we need to be consider a user may be working offline and not connected to the internet or the Spotfire server. If this is not a concern, you can code the instructions in an HTML page and post them on a web server.  


Then we need to launch a .NET windows.form which contains a Web Browser. The following code will launch a Web Browser in a windows.form control and display www.server.com/instructions.html inside it.

import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import Form, DockStyle, WebBrowser

f = Form()
f.Text = 'Instructions'
f.Width = 800
f.Height = 600

wb = WebBrowser()
wb.Navigate("http://www.myserver.com/instructions.html")

# Layout
wb.Dock = DockStyle.Fill
f.Controls.Add(wb)

# Display the Control

f.ShowDialog()

Let’s assume you cannot simply point to a file on a web server and you would like to keep the intstructions directly inside the Analysis File.    The best way to do this would be to write the instructions to a string, which is then stored in a temporary file, and referenced in the WebBrowser control.


import clr
clr.AddReference("System.Windows.Forms")
from System.IO import Path, File
from System.Text import StringBuilder
from System.Windows.Forms import Form, DockStyle, WebBrowser

sb = StringBuilder()
sb.Append("<h1>Instructions for this Analysis</h1>")
sb.Append("<p>Here you need to check to see if blah blah blah</p>")
sb.Append("<p>After that you need to check to see if blah blah blah</p>")

tempfilename = Path.GetTempFileName()
newHTMLFile = Path.ChangeExtension(tempfilename, ".html")
tempfile = open(newHTMLFile, 'w+b')
tempfile.write(sb.ToString())
tempfile.close()

f = Form()
f.Text = 'Instructions'
f.Width = 800
f.Height = 600

wb = WebBrowser()
wb.Navigate(newHTMLFile)

# Layout
wb.Dock = DockStyle.Fill
f.Controls.Add(wb)

# Display the Control
f.ShowDialog()

#Must delete the temp files so they do not persist on the users’ computer
File.Delete(newHTMLFile)
File.Delete(tempfilename)      

A third option would be to list the instructions in a Document Property rather than as a string inside the Script.  To do this, you can create a Document Property and then store the instructions in that. The value of the property is limited, but there is more characters allowed in the Description, so you can use that field to enter the instructions.

 


Then in your script, instead of building a string to pass in the instructions to the Web Browser, we can reference the description of this property and pass that in. Assuming our property is called page1Instructions, we can use the following code to reference the Description of that property.

strInstructions = Document.Data.Properties.GetProperty(DataPropertyClass.Document, "page1Instructions").Description

The complete script for this third option is shown below:

import clr
clr.AddReference("System.Windows.Forms")
from System.IO import Path, File
from System.Windows.Forms import Form, DockStyle, WebBrowser
from Spotfire.Dxp.Data import DataPropertyClass

strInstructions = Document.Data.Properties.GetProperty(DataPropertyClass.Document, "page1Instructions").Description

tempfilename = Path.GetTempFileName()
newHTMLFile = Path.ChangeExtension(tempfilename, ".html")
tempfile = open(newHTMLFile, 'w+b')
tempfile.write(strInstructions)
tempfile.close()

f = Form()
f.Text = 'Instructions'
f.Width = 800
f.Height = 600

wb = WebBrowser()
wb.Navigate(newHTMLFile)

# Layout
wb.Dock = DockStyle.Fill
f.Controls.Add(wb)

# Display the Control
f.ShowDialog()

#Must delete the temp files so they do not persist on the users’ computer
File.Delete(newHTMLFile)
File.Delete(tempfilename)       


Yet another solution would be to add a description into each Visualization using its Properties dialog. Then have the Script loop through all Visualization’s on the page and append its Title and Description using the StringBuilder.


Remember, this solution only works in Spotfire Professional and Spotfire Enterprise Player, it will not work in Spotfire Web Player since it’s a .NET windows control we are displaying.  We will show you in an upcoming post how to create similar instructional dialogs for your files that you will share over the Web Player. To learn more about Script Controls, consider taking SP232: Automation APIs using IronPython

Comments

 

hvmarck said:

Isn't it easier to use wb.DocumentText instead? So the script would become:

import clr

clr.AddReference("System.Windows.Forms")

from System.Windows.Forms import Form, DockStyle, WebBrowser

strInstructions = Document.Data.Properties.GetProperty(DataPropertyClass.Document, "page1Instructions").Description

f = Form()

f.Text = 'Instructions'

f.Width = 800

f.Height = 600

wb = WebBrowser()

wb.DocumentText=strInstructions

# Layout

wb.Dock = DockStyle.Fill

f.Controls.Add(wb)

# Display the Control

f.ShowDialog()

Also why not store the instructions in a text area on a separate 'Instructions' page, and retrieve its HTML to display.

Finally, why not use the active Visualisation to show context dependant help?

August 2, 2010 3:35 AM
 

Kevin Hanegan said:

Yes, using DocumentText would be much easier , thanks! I was not aware of DocumentText, but now I will use that moving forward!

Yes, you can also store the instructions in a separate 'instructions' page, and that is another good example.  I was just thinking of ways to store it so it was not visible at all, but this is good option and probably easier than storing the text in the code. (It would be great if we could hide pages in the future).

For using the active visualization, that would be nice as well, but you have to click on the button in the text area, making the active visualization always the text area and not the visualizations.

August 2, 2010 8:55 PM
 

Tip of the Week said:

In an earlier post , we discussed how to add instructions into an Analysis File which was meant to be

September 27, 2010 8:20 AM
 

uggkensington said:

http://www.uggkensingtons.org/

http://www.uggkensingtons.org/ugg-fox-fur-short-boots-5531-c-54.html | UGG Fox Fur Short Boots 5531

http://www.uggkensingtons.org/ugg-kensington-boots-5678-c-2.html | UGG Kensington Boots 5678

http://www.uggkensingtons.org/ugg-rainier-eskimo-boots-5189-c-85.html | UGG Rainier Eskimo Boots 5189

http://www.uggkensingtons.org/ugg-retro-cargo-boots-1895-c-3.html | UGG Retro Cargo Boots 1895

December 27, 2011 8:13 PM
 

uggskensingtonsale said:

www.uggskensingtonsale.org

www.uggskensingtonsale.orgugg-adirondack-boots-ii-c-6.html | UGG Adirondack Boots II

www.uggskensingtonsale.orgugg-adirondack-tall-boots-c-11.html | UGG Adirondack Tall Boots

www.uggskensingtonsale.orgugg-amberlee-boots-c-34.html | UGG Amberlee Boots

www.uggskensingtonsale.orgugg-annabelle-boots-c-35.html |

December 28, 2011 4:16 AM
 

uggretrocargosale said:

January 4, 2012 8:48 PM

Leave a Comment

(required) 
(optional)
(required) 
Submit

Syndication

Tags

Other Spotfire Blogs

Spotfire's interactive information visualization and analytic solutions give users a remarkable experience for quickly and easily querying data and reporting results for superior business intelligence. From portfolio management and customer retention programs to key processes such as CRM, marketing, research, bioinformatics, yield and asset management and design for manufacturing, enterprises around the world rely on Spotfire's business analytics software to improve operational performance.

©Copyright 2000-2011 TIBCO Software Inc | Privacy Policy | Terms of Use I Blog I Contact Us I Content Center