Python Reference Guide
 
Loading...
Searching...
No Matches
UI\Popup.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 that will create and close a FBPopup
8#
9# Topic: FBButton, FBPopup
10#
11
12from pyfbsdk import *
13from pyfbsdk_additions import *
14
15# Button creation
16def ShowPopupCallback(control, event):
17 global t
18 popup.Show(t)
19
20# a Popup is really a layout. It should be populated/initialized
21def ClosePopupCallback(control, event):
22 popup.Close(True)
23
24
25def PopulateLayout(mainLyt):
26 # create a button on the tool that will show the popup
27 b = FBButton()
28 b.Caption = "Pop up"
29
30 x = FBAddRegionParam(10,FBAttachType.kFBAttachLeft,"")
31 y = FBAddRegionParam(10,FBAttachType.kFBAttachTop,"")
32 w = FBAddRegionParam(50,FBAttachType.kFBAttachNone,"")
33 h = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
34
35 mainLyt.AddRegion("Btn","Btn", x, y, w, h)
36 mainLyt.SetControl("Btn",b)
37
38 b.OnClick.Add(ShowPopupCallback)
39
40 # create the popup
41 global popup
42 popup = FBPopup()
43 popup.Caption = "Popup"
44 popup.Modal = False
45
46 popup.Left = 300
47 popup.Top = 300
48 popup.Width = 400
49 popup.Height = 500
50
51 b = FBButton()
52 b.Caption = "Close"
53 b.OnClick.Add(ClosePopupCallback)
54
55
56 popup.AddRegion( "Close", "Close", x, y ,w,h )
57 popup.SetControl("Close", b)
58
59def CreateTool():
60 # Tool creation will serve as the hub for all other controls
61 global t
62 t = FBCreateUniqueTool("Popup Example")
63 PopulateLayout(t)
64 ShowTool(t)
65
66
67CreateTool()
68
Used to create and manage buttons in a user interface.
Definition: pyfbsdk_generated.h:2442
Popup window.
Definition: pyfbsdk_generated.h:14318