What I discovered was that you can not reliably execute any code after a call to the selector, so I ended up with an even handler like this.
if evt == DO_BROWSE:
Blender.Window.FileSelector(process_browse, 'Select an OBJ file')
# NOTE: Just because we called the file selector does not mean the code flow has stopped.
# Nothing else can be done after the call to the FileSelector.
Then, as you mention use globals in the callback function to take care of any extra parameters you require.
Here is my Meshfoot process_browse.
def process_browse(passedFileName):
# Global Draw.objects.
global name,version
global txtFootageName,txtFootagePath,sldFootageEnd
# Global footage container.
#global mfFootage,gCurrentFootageIndex
Blender.Window.WaitCursor(1)
cfi = Meshfoot_LIB_v01.gCurrentFootageIndex
localmfFootage = Meshfoot_LIB_v01.mfFootage[cfi]
outputText ("User selected file [" + passedFileName + "]")
fileParts = passedFileName.split("\\")
localmfFootage.file_name = passedFileName
localmfFootage.footage_name = fileParts[-1] # Temporarily save here, gets parsed down further.
l1 = len(localmfFootage.footage_name)
if l1 > 0:
l2 = len(passedFileName)
outputText("Operating on Footage Index:" + str(cfi))
localmfFootage.footage_path = passedFileName[:(l2-l1)]
moreParts = localmfFootage.footage_name.split(".")
localmfFootage.footage_extension = "." + moreParts[-1]
l1 = len(localmfFootage.footage_extension)
l2 = len(localmfFootage.footage_name)
localmfFootage.footage_name = localmfFootage.footage_name[:(l2-l1)] # Remove extension.
localmfFootage.footage_name = removeTrailingNumbers(localmfFootage.footage_name) # Get rid of trailing number sequence.
txtFootageName.val = localmfFootage.footage_name
txtFootagePath.val = localmfFootage.footage_path
# Try to figure out how many frames are in this "Browsed" to OBJ sequence.
tempFound, tempSkipped = reviewFileSequence(localmfFootage)
if tempFound > 1:
sldFootageEnd.val = localmfFootage.footage_start + (tempFound-1) # Assign the found count to the footage end slider.
localmfFootage.footage_end = sldFootageEnd.val
# Time to load all those OBJ files into memory.
localScene = Scene.GetCurrent()
r = loadMeshSequence (localmfFootage, localScene)
if r == True:
reviewFootage(localmfFootage) # Set status flags for this footage.
synchINIToGUI() # Write the internal information to the INI, then populate GUI from INI.
else:
r = MsgBox (name + " - Version: " + version,"Problem loading OBJ sequence.")
else:
r = MsgBox (name + " - Version: " + version,"No OBJ sequence detected.")
else:
outputText ("Problem parsing footage file name [" + passedFileName + "]")
Blender.Window.WaitCursor(0)