siva sai 2 Posted March 25, 2016 Share Posted March 25, 2016 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 More sharing options...
Shandilya Peddi Posted April 10, 2019 Share Posted April 10, 2019 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 vis=txtArea.As[HtmlTextArea]() # 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 image1Exists=vis.Images.Contains("image1") image2Exists=vis.Images.Contains("image2") image3Exists=vis.Images.Contains("image3") #Add the images to the collection if not already added if not image1Exists: vis.Images.Add("image1",image1,ImageFormat.Png) if not image2Exists: vis.Images.Add("image2",image2,ImageFormat.Jpeg) if not image3Exists: vis.Images.Add("image3",image3,ImageFormat.Png) #Get which Image to be shown imageName=Document.Properties["showImage"] #Get the current html content content=vis.HtmlContent #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 ); vis.HtmlContent=input else: #code to add the HTML Image element the first time addImage= "" vis.HtmlContent=addImage+content Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now