def _getScriptOpenOptions(): l = FnAssetAPI.l msgBox = QtWidgets.QMessageBox() msgBox.setText(l("{published} Scripts can't be opened directly.")) msgBox.setInformativeText( "This is to avoid changing the asset itself by " + "saving. Would you like to Save a Copy or import the nodes?") saveAs = msgBox.addButton("Save As...", msgBox.AcceptRole) imp = msgBox.addButton("Import", msgBox.NoRole) # Had some issues with StandardButton .vs. AbstractButton msgBox.addButton("Cancel", msgBox.RejectRole) msgBox.exec_() button = msgBox.clickedButton() if button == saveAs: return 'saveas' elif button == imp: return 'import' else: return ''
def confirmClose(): l = FnAssetAPI.l msgBox = QtWidgets.QMessageBox() msgBox.setText(l("Save changes before closing script?")) msgBox.setStandardButtons(QtWidgets.QMessageBox.Save | QtWidgets.QMessageBox.Discard | QtWidgets.QMessageBox.Cancel) button = msgBox.exec_() if button == QtWidgets.QMessageBox.Save: return 'save' elif button == QtWidgets.QMessageBox.Discard: return 'dontsave' else: return 'cancel'