Radio Button with Confirm Popup Window

gui locking popups are a pet peeve of mine, but if you must do it this way, here's how:

Example:
First, add a custom property to the parent container called selectedButton:
image

Then, add this script to the actionPerfomed event handler of the radio buttons:

# Make sure the user is sure
if system.gui.confirm('Are you sure?', 'Confirm'):
	
	# If so, update the parent container's selectedButton property
	# ...to trigger the action script
	event.source.parent.selectedButton = event.source.name

# Otherwise, revert the changes by reselecting the previously confirmed radio button
elif event.source.parent.selectedButton:
	event.source.parent.getComponent(event.source.parent.selectedButton).selected = True

Finally, add this script to the propertyChange event handler of the parent container:

# Only fire if a new selection is confirmed
if event.propertyName == 'selectedButton':
	# Do work here
	
	print 'working!'

The act of confirming the button will store the button's name on the parent container and trigger a propertyChange event to actually carry out the work of the button. If the user declines to confirm the selection, the name of the last confirmed button will simply be retrieved from the parent container and used to reselect the previous button.

2 Likes