BasicOperations/GetUserValue.py

BasicOperations/GetUserValue.py
1 # Copyright 2009 Autodesk, Inc. All rights reserved.
2 # Use of this software is subject to the terms of the Autodesk license agreement
3 # provided at the time of installation or download, or which otherwise accompanies
4 # this software in either electronic or hard copy form.
5 #
6 # Script description:
7 # Shows how FBMessageBoxGetUserValue can be used to select options or as an Ok-Cancel dialog.
8 #
9 # Topic: FBMessageBoxGetUserValue, FBMessageBox
10 #
11 
12 from pyfbsdk import *
13 
14 # note that the last params of FBMessageBoxGetUserValue indicates if the last button act as a cancel button.
15 
16 # if lastButtonIsCancel is set to True (its default value), and you click the last displayed button, the value is NOT updated.
17 lastButtonIsCancel = True
18 btn, value = FBMessageBoxGetUserValue("Rename","Enter new name:", "", FBPopupInputType.kFBPopupString,"Ok","Cancel", None, 1, lastButtonIsCancel)
19 
20 if btn == 1:
21  msg = "Name has been changed to %s" % (value)
22 else:
23  msg = "Name has not been changed, value has not been updated."
24 FBMessageBox("What happened:", msg, "Ok")
25 
26 # if lastButtonIsCancel is set to False, and you click any button the user value is updated
27 lastButtonIsCancel = False
28 btn, value = FBMessageBoxGetUserValue("Select Choices","Enter a value and select an action:", "", FBPopupInputType.kFBPopupString,"Do this","Do that", "Do it that way", 1, lastButtonIsCancel)
29 if btn == 1:
30  msg = "Do this with value %s" % (value)
31 elif btn == 2:
32  msg = "Do that with value %s" % (value)
33 else:
34  msg = "Do it that way with value %s" % (value)
35 FBMessageBox("What happened:", msg, "Ok")