# 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: FBFilePopup, FBFilePopupStyle
#

from pyfbsdk import FBFilePopup, FBFilePopupStyle, FBMessageBox

# Create the popup and set necessary initial values.
lFp = FBFilePopup()
lFp.Caption = "FBFilePopup example: Select a file"
lFp.Style = FBFilePopupStyle.kFBFilePopupOpen

# BUG: If we do not set the filter, we will have an exception.
lFp.Filter = "*"

# Set the default path.
lFp.Path = r"C:\Program Files"

# Get the GUI to show.
lRes = lFp.Execute()

# If we select files, show them, otherwise indicate that the selection was canceled.
if lRes:
  FBMessageBox( "FBFilePopup example", "Selected file:\n  Name: '%s'\n  Path: '%s'" % ( lFp.FileName, lFp.Path ), "OK", None, None )
else:
  FBMessageBox( "FBFilePopup example", "Selection canceled", "OK", None, None )

# Cleanup.
del( lFp, lRes, FBFilePopup, FBFilePopupStyle, FBMessageBox )