I need to configure a message to pop up when they click the help "question mark" button.
CodePudding user response:
As far as I can find out, the cmds.confirmDialog
wrapper does not provide a hook for WhatsThis text, nor does it provide access to the underlying QMessageBox.
However, if you're keen enough, you can roll your own. This code assumes Maya2020/PySide2:
from PySide2 import QtWidgets, QtCore
box = QtWidgets.QMessageBox(
QtWidgets.QMessageBox.Icon.Question,
'Message title',
'Message body goes here.\n\nHere are some more words to make the size a bit more reasonable',
QtWidgets.QMessageBox.StandardButton.Ok|QtWidgets.QMessageBox.StandardButton.Cancel,
None,
QtCore.Qt.Dialog|QtCore.Qt.MSWindowsFixedSizeDialogHint|QtCore.Qt.WindowContextHelpButtonHint
)
box.setWhatsThis('This is the WhatsThis text...')
box.button(QtWidgets.QMessageBox.StandardButton.Ok).setText('Import')
res = box.exec_()
if res == QtWidgets.QMessageBox.StandardButton.Ok:
print('User wants import')
else:
print('User wants to cancel')
It's worth pointing out that the question-mark-box/WhatsThis text probably isn't what you're hoping it will be. Run the above example and see if it fits your needs.
Cheers