System.gui.confirm - Text Formatting

Hi, I am using the below script in button. But alignment of the text is not good. Any way to adjust my script?

i = 0
tag_check_neagtive = ["[default]Montreal/Weather/Description","[default]Montreal/Weather/Description","[default]Montreal/Weather/Description"]

negative_message = 'Minimum and Maximun retrieval modes for data extraction are unavailable for string type data. \nIf you want to proceed with other retrieval methods click OK. To remove these tags from the order click REMOVE.'
for y in tag_check_neagtive:
	
		negative_message = negative_message +'\n'+ str(tag_check_neagtive[i])
		
system.gui.confirm(negative_message,"Confirm")

can any help me for text formatting

You could try adding <html> to your string:

i = 0
tag_check_neagtive = ["[default]Montreal/Weather/Description","[default]Montreal/Weather/Description","[default]Montreal/Weather/Description"]

negative_message = '<html>Minimum and Maximun retrieval modes for data extraction are unavailable for string type data. \nIf you want to proceed with other retrieval methods click OK. To remove these tags from the order click REMOVE.'
for y in tag_check_neagtive:
	
		negative_message = negative_message +'\n'+ str(tag_check_neagtive[i])
		
system.gui.confirm(negative_message,"Confirm")

1 Like

One question
image

is there any way to rename yes and no button - instead of confirm and remove?

Not that I am aware of. Creating a custom pop-up window would probably be the simplest approach.

Custom popup any script you have with you?

Replace your current button code with something like this:
system.nav.openWindow('YourPopupPath/removeTagConfirm')

Then, create a custom popup window with the buttons you want. You will have to use a label in the popup for your message, The code will look something like this:

i = 0
tag_check_neagtive = ["[default]Montreal/Weather/Description","[default]Montreal/Weather/Description","[default]Montreal/Weather/Description"]

negative_message = 'Minimum and Maximun retrieval modes for data extraction are unavailable for string type data. \nIf you want to proceed with other retrieval methods click OK. To remove these tags from the order click REMOVE.'
for y in tag_check_neagtive:
	
		negative_message = negative_message +'\n'+ str(tag_check_neagtive[i])
		
event.source.parent.getComponent('tagDeleteConfirmationLabel').text = negative_message

Then you can program the confirm and remove buttons to do whatever you need them to do, and you can change the text properties of the buttons to whatever you want

1 Like

I assume that you will probably want to run the above script from the window’s internalFrameOpened event handler

1 Like

Another option would be to create your own JOptionPane instances. This requires some more scripting know-how, but is more powerful:
https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/javax/swing/JOptionPane.html

2 Likes

Paul Griffith’s suggestion was actually pretty simple to implement. Now that I’ve used it, I remembered this post, and I’ve reformatted the code to fit the context of this question. Here it is:

from javax.swing import JOptionPane
i = 0
tag_check_neagtive = ["[default]Montreal/Weather/Description","[default]Montreal/Weather/Description","[default]Montreal/Weather/Description"]
negative_message = '<html>Minimum and Maximun retrieval modes for data extraction are unavailable for string type data. \nIf you want to proceed with other retrieval methods click OK. To remove these tags from the order click REMOVE.'
for y in tag_check_neagtive:
		negative_message = negative_message +'\n'+ str(tag_check_neagtive[i])
JOptionPane.showOptionDialog(None, negative_message, "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, None, ["Confirm", "Remove"], "Confirm")

The preceding code produces this result:

4 Likes