I’ve noticed recently that I haven’t been able to control which button is the default when using MessageBox in a Python script. According to the help file 256 assigns the second button as the default.
I’ve used this for years, but recently it doesn’t seem to be working for me. Here is an example:
not ideal, but could you use a windows form directly?
(python example). Rhino 6
import System.Windows.Forms as wf
message = "The default button is No"
caption = "MessageBoxAlternative"
result = wf.MessageBox.Show(message, caption, wf.MessageBoxButtons.YesNoCancel, \
wf.MessageBoxIcon.Question, wf.MessageBoxDefaultButton.Button2)
print result
Why not use an Eto Form? I do this in one of mine. Here is an example with No as the default:
import Eto.Forms as forms
from Eto.Forms import MessageBox, MessageBoxButtons, MessageBoxDefaultButton, MessageBoxType, DialogResult
rs.UnitSystem(4, False, True)
title = 'Do you want meters for distance unit?'
message = 'Click on Yes if you want meters'
# Displays a MessageBox using the Question icon and specifying the No button as the default.
result = MessageBox.Show(message, title, MessageBoxButtons.YesNo, MessageBoxType.Question, MessageBoxDefaultButton.No)
if result == DialogResult.No:
# Set units to feet.
rs.UnitSystem(9, True, True)