Trying to add further graphical detail to warning pop up following the use of a Data-Shapes UI script

I am using a script given by @salvatoredragotta In this post which functions perfectly in generating a popup after the script has run, using a warning generated as a System Windows form.

Although the pop up works as it says on the tin, I was just looking to add a little more control to the popup; such as CenterScreen and any appearance adjustments.

Unfortunately, due to my lack of Python knowledge I can’t seem to adjust the code to make any changes.

I tried to apply some intuition and help from Google which lead me to the conclusion that the start position should be defined when the Form is being initially run. But I cant seem to get it into the Python script to make it work.

This is what I tried:
CentreScreen

Forgive my ignorance, but what am I doing wrong? Many examples online seem to be defining the location in a ‘protected void’. But I tried using this method too & again couldn’t work out where this should be located in the script.

Thanks in advance for any help.

@haganjake2

import clr

clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import Form,Label,FormStartPosition

def popup(text):
	form = Form()
    form.StartPosition = FormStartPosition.CenterScreen
	form.Width = 300
	form.Height = 100	
	label = Label()
	label.Text = text
	label.Width = 280
	label.Height = 70
	label.Parent = form	
	form.ShowDialog()
	
Text="\n".join(IN[0])
popup(Text)
1 Like

Great!

Thanks for your help.

Hi @salvatoredragotta ,

I don’t suppose you would know where to implement some form of SetForegroundWindow for the form?

Had a few issues in use where the form is hidden behind other windows.

Thanks,
Jake

Sorry to pester @salvatoredragotta - Just wondered if you could take a brief look at my question above?

Thanks,
Jake

@haganjake2 try:

form.TopMost = True

Worked a treat! Thanks again

1 Like