# Copyright 2009 Autodesk, Inc. All rights reserved. # Use of this software is subject to the terms of the Autodesk license agreement # provided at the time of installation or download, or which otherwise accompanies # this software in either electronic or hard copy form. # # Topic: FBMessageBoxGetUserValue, FBMessageBox, FBPopupInputType # from pyfbsdk import FBMessageBoxGetUserValue, FBMessageBox, FBPopupInputType # First, let's have a utility function to test the different input types. def TestMessageBox( pVal, pType ): # The result from the call will be a tuple containing the index of the # button pressed (or -1 in case of error). The second element will be # the value entered. lRes = FBMessageBoxGetUserValue( "Value type: '%s'" % pType, "Value: ", pVal, pType, "Ok" ) # Did the user press 'Ok'? if lRes[0]: # Show the value entered. FBMessageBox( "Result", "Value entered: '%s'" % lRes[1], "Ok" ) else: # Or tell that there was an error... FBMessageBox( "Result", "Got an error", "Ok" ) del( lRes ) # The message box does not handle booleans well... let's skip those for now. # TestMessageBox( True, FBPopupInputType.kFBPopupBool ) # TestMessageBox( False, FBPopupInputType.kFBPopupBool ) # Lets try to get a single character, no default value. TestMessageBox( None, FBPopupInputType.kFBPopupChar ) # Now with 'X' as a default value. TestMessageBox( 'X', FBPopupInputType.kFBPopupChar ) # Now with a string. TestMessageBox( "Default string value", FBPopupInputType.kFBPopupString ) # Now as if we were asking for a password. No default value for the password. TestMessageBox( None, FBPopupInputType.kFBPopupPassword ) # An integer... TestMessageBox( 33, FBPopupInputType.kFBPopupInt ) # A float... TestMessageBox( 3.14e3, FBPopupInputType.kFBPopupFloat ) # A double... TestMessageBox( 3.1416, FBPopupInputType.kFBPopupFloat ) # Cleanup. del( TestMessageBox, FBMessageBoxGetUserValue, FBMessageBox, FBPopupInputType )