UI/TabPanel.py

UI/TabPanel.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 # Create a tool with a tabpanel that automatically manages all clicking on tabs to display the relevant content.
8 #
9 # Topic: FBTabPanel, FBBorderStyle, FBTabControl
10 #
11 
12 from pyfbsdk import *
13 from pyfbsdk_additions import *
14 
15 
16 def PopulateLayout(mainLyt):
17  tab = FBTabControl()
18 
19  # insert tab control
20  x = FBAddRegionParam(10,FBAttachType.kFBAttachLeft,"")
21  y = FBAddRegionParam(10,FBAttachType.kFBAttachTop,"")
22  w = FBAddRegionParam(-10,FBAttachType.kFBAttachRight,"")
23  h = FBAddRegionParam(-10,FBAttachType.kFBAttachBottom,"")
24 
25  mainLyt.AddRegion("tab", "tab",x,y,w,h)
26  mainLyt.SetControl("tab", tab)
27 
28 
29  # Create dummy layout that will be "tabbable"
30  for i in range(3):
31  name = "%s %d" % ("Tab ", i + 1)
32 
33  l = FBLayout()
34 
35  x = FBAddRegionParam(10,FBAttachType.kFBAttachLeft,"")
36  y = FBAddRegionParam(10,FBAttachType.kFBAttachTop,"")
37  w = FBAddRegionParam(-10,FBAttachType.kFBAttachRight,"")
38  h = FBAddRegionParam(-10,FBAttachType.kFBAttachBottom,"")
39  l.AddRegion(name,name, x, y, w, h)
40  # each layout will have a visible border
41  l.SetBorder(name,FBBorderStyle.kFBStandardBorder,True, True,1,0,90,0)
42 
43  tab.Add(name,l)
44 
45 
46  tab.SetContent(0)
47  tab.TabPanel.TabStyle = 0 # normal tabs
48  #tab.TabPanel.TabStyle = 1 # tabs are activated with buttons
49 
50 def CreateTool():
51  # Tool creation will serve as the hub for all other controls
52  t = FBCreateUniqueTool("TabPanel Example")
53  t.StartSizeX = 400
54  t.StartSizeY = 400
55  PopulateLayout(t)
56  ShowTool(t)
57 
58 CreateTool()