|
Hi,
well your suggestions were the first ones that came into my mind when I had the same problem. ;)
In some of the example scripts provided by autodesk they had a totally different approach by setting the actual tool to global:
def CreateTool():
global tool
tool = CreateUniqueTool("Property Example")
tool.StartSizeX = 400
tool.StartSizeY = 200
PopulateLayout(tool)
ShowTool(tool) CreateTool()
Later in the PopulateLayout-Function you can access this tool very easily. Here shown in the autodesk example script:
... def PopulateLayout(mainLyt):
x = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
y = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
w = FBAddRegionParam(0,FBAttachType.kFBAttachRight,"")
h = FBAddRegionParam(25,FBAttachType.kFBAttachBottom,"")
mainLyt.AddRegion("main","main", x, y, w, h)
vlyt = VBoxLayout()
mainLyt.SetControl("main",vlyt)
l = FBLabel()
l.Caption = "Drag and drop a model into the container. Double click to clear."
vlyt.Add(l,30)
tool.model = None
tool.container = FBContainer()
tool.container.OnDragAndDrop.Add(EventContainerDragAndDrop)
tool.container.OnDblClick.Add(EventContainerDblClick)
vlyt.Add(tool.container,30)
...
In your own code just create a list and make sure it is added to the tool like in the first line below:
... tool.myDropDownList = FBList() tool.myDropDownList.Style = FBListStyle.kFBDropDownList for obj in myList:
tool.myDropDownList.Items.append(obj.Name) lyt.Add(tool.myDropDownList, 20) #add line 2 with 20 pixels from the top ...
myList contains the actual list that will be shown in the dropdown-list, e.g. myList=["one”,"two”,"three"].
After you set up your button(FBButton()) in its callback-function you can easily access the items in the list with tool.<<your list>>:
def ButtonCallback(control, event):
myList = tool.myDropDownList.Items[tool.myDropDownList.ItemIndex]
print tool.myDropDownList.Items[tool.myDropDownList.ItemIndex]+" is ready to be processed"
# put the rest of the script here
Cheers,
Chris
|