Python Reference Guide
 
Loading...
Searching...
No Matches
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
12from 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.
17lastButtonIsCancel = True
18btn, value = FBMessageBoxGetUserValue("Rename","Enter new name:", "", FBPopupInputType.kFBPopupString,"Ok","Cancel", None, 1, lastButtonIsCancel)
19
20if btn == 1:
21 msg = "Name has been changed to %s" % (value)
22else:
23 msg = "Name has not been changed, value has not been updated."
24FBMessageBox("What happened:", msg, "Ok")
25
26# if lastButtonIsCancel is set to False, and you click any button the user value is updated
27lastButtonIsCancel = False
28btn, value = FBMessageBoxGetUserValue("Select Choices","Enter a value and select an action:", "", FBPopupInputType.kFBPopupString,"Do this","Do that", "Do it that way", 1, lastButtonIsCancel)
29if btn == 1:
30 msg = "Do this with value %s" % (value)
31elif btn == 2:
32 msg = "Do that with value %s" % (value)
33else:
34 msg = "Do it that way with value %s" % (value)
35FBMessageBox("What happened:", msg, "Ok")
int FBMessageBox(str pBoxTitle, str pMessage, str pButton1Str, str pButton2Str=None, str pButton3Str=None, int pDefaultButton=0, int pScrolledMessage=0)
Dialog popup box.