UI/FBFilePopup.py

UI/FBFilePopup.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 # Topic: FBFilePopup, FBFilePopupStyle
7 #
8 
9 from pyfbsdk import FBFilePopup, FBFilePopupStyle, FBMessageBox
10 
11 # Create the popup and set necessary initial values.
12 lFp = FBFilePopup()
13 lFp.Caption = "FBFilePopup example: Select a file"
14 lFp.Style = FBFilePopupStyle.kFBFilePopupOpen
15 
16 # BUG: If we do not set the filter, we will have an exception.
17 lFp.Filter = "*"
18 
19 # Set the default path.
20 lFp.Path = r"C:\Program Files"
21 
22 # Get the GUI to show.
23 lRes = lFp.Execute()
24 
25 # If we select files, show them, otherwise indicate that the selection was canceled.
26 if lRes:
27  FBMessageBox( "FBFilePopup example", "Selected file:\n Name: '%s'\n Path: '%s'" % ( lFp.FileName, lFp.Path ), "OK", None, None )
28 else:
29  FBMessageBox( "FBFilePopup example", "Selection canceled", "OK", None, None )
30 
31 # Cleanup.
32 del( lFp, lRes, FBFilePopup, FBFilePopupStyle, FBMessageBox )