Jump to content

Is it posssible to Change Text Area Image Dynamically

Recommended Posts

Hi Everyone,

I have a poperty control in Textarea with three vlaues A,B and C and each value has a different image to be shown in the same text area where this property control resides . Means i have a inserted image in spotfire and it has to be changed on the property control selection.

Thanks in Advance

Link to comment
Share on other sites

  • 3 years later...

Below are the steps to do the needed,

1. To be able to change the images shown in the Text Area dynamically, first we need to add the images to the ImageCollection and then change as needed

Below is a sample script that add/changes the images as needed

from Spotfire.Dxp.Application.Visuals import *

from System.IO import *

from System.Drawing import *

from System.Drawing.Imaging import *

from System.Text.RegularExpressions import *


#Add txtArea as a script parameter referring to the TextArea




# Add images from a file

image1 = Image.FromFile(r"C:Users\Downloadsimage001.png");

image2 = Image.FromFile(r"C:Users\Downloadsimage001.jpg");

image3 = Image.FromFile(r"C:Users\Downloadsimage001 (2).png");


#Check if the images already exist in the collection





#Add the images to the collection if not already added

if not image1Exists:


if not image2Exists:


if not image3Exists:



#Get which Image to be shown



#Get the current html content



#check if HTML image element is already present

htmlImage=content.Contains("img src")



if htmlImage:

#code to replace the image

input = vis.HtmlContent;

oldValue = Regex.Match(input, ""(.+)"").Groups[1].Value;

input = input.Replace(oldValue,imageName );



#code to add the HTML Image element the first time

addImage= ""


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...