UI/ToolCommunicationSender.py

UI/ToolCommunicationSender.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 # This tool is used with ToolCommunicationReceiver.
8 # Retrieved the Receiver from the FBToolList and add a "ping" to its vertical list.
9 #
10 
11 
12 from pyfbsdk import *
13 from pyfbsdk_additions import *
14 
15 
16 # Tool creation will serve as the hub for all other controls
17 t = FBCreateUniqueTool("Sender")
18 t.StartSizeX = 400
19 t.StartSizeY = 400
20 x = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
21 y = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
22 w = FBAddRegionParam(75,FBAttachType.kFBAttachNone,"")
23 h = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
24 t.AddRegion("main","main", x, y, w, h)
25 
26 pingcount = 0
27 
28 def pingReceiver(control,event):
29  if FBToolList.has_key("Receiver"):
30  receiver = FBToolList["Receiver"]
31  global pingcount
32 
33  receiver.receivedList.Items.append("ping# %d" % pingcount)
34  pingcount+= 1
35  else:
36  FBMessageBox( "Message", "Receiver Tool not instantiated.", "OK", None, None )
37 
38 b = FBButton()
39 b.Caption = "Ping Receiver"
40 b.OnClick.Add(pingReceiver)
41 t.SetControl("main",b)
42 
43 ShowTool(t)