Perspective Line Breaks in text label/markdown

Try this:

if tag_check_neagtive:	
    negative_message = 'This chart is unavailable for string type data. Please unselect the tags listed below from the Tag Tree Browser.'

    negative_message += '<br/>'.join([r'\[{}\]{}'.format(tag.source,tag.toStringPartial()) for tag in tag_check_neagtive])

    system.perspective.openPopup("Warning", "test", 
                                 {"message": negative_message}, "Error", 
                                 modal=True, showCloseIcon=True, draggable=False, resizable=False)

Or you can replace [ with HTML entity &#91; and ] with &#93;.

By the way, I think you have spelt "negative" incorrectly in "tag_check_neagtive:". You might want to fix that.

This will also work, I've just always found that very cryptic.

I noticed the typo as well.

getting some error

negative_message += '<br/>'.join([r'\[{}\]{}'.format(tag.source,tag.toStringPartial()) for tag in tag_check_neagtive])

code is not passing this line

Hard to help if I don't know what the error is.

com.inductiveautomation.ignition.common.script.JythonExecException
Traceback (most recent call last):
  File "<function:onMessageReceived>", line 87, in onMessageReceived
AttributeError: 'unicode' object has no attribute 'source'

	caused by org.python.core.PyException
Traceback (most recent call last):
  File "<function:onMessageReceived>", line 87, in onMessageReceived
AttributeError: 'unicode' object has no attribute 'source'

Okay, so the list, is really a list of strings, not TagPath objects.

if tag_check_neagtive:	
    negative_message = 'This chart is unavailable for string type data. Please unselect the tags listed below from the Tag Tree Browser.'

    negative_message += '<br/>'.join([r'\[{}\]{}'.format(tag[1:tag.find(']')],tag[tag.find(']') + 1:]) for tag in tag_check_neagtive])

    system.perspective.openPopup("Warning", "test", 
                                 {"message": negative_message}, "Error", 
                                 modal=True, showCloseIcon=True, draggable=False, resizable=False)
1 Like

Its working there is syntax error i have corrected it

negative_message += '<br/>'.join([r'\[{}\]{}'.format(tag[1:tag.find(']')], tag[tag.find(']') + 1:]) for tag in tag_matched])

1 Like

As an alternative, you can also use re.split to split by multiple delimiters, instead of using find:

import re
a = '[default]tag/path'
re.split('\[|\]', a)[1:] # split by "[" or "]", discarding the first find

>> ['default', 'tag/path']
1 Like