| Example 1, Coordinate transforms 
 def execute(self,image):
  # use self.name to get this tool instance
  # tool=GetTool(self.name)
  # image parameter is a python image matrix due to ROI
  # Return 1 for pass, 0 for fail
     def PrintPoint(txt,p):
    '''
    print formatted point
    '''
    print txt,'(%.1f, %.1f)'%(p[0],p[1])  def DrawPoint(ref,p,col,idx):
    '''
    draws a marker and coordinate text in ref's object coords
    '''
    DrawMarker(ref,p[0],p[1],col)
    DrawText(ref,p[0],p[1],'%d:(%d,%d)'%(idx,p[0],p[1]),'yellow',8)  t=BaseTool(self.name)            #get the BaseTool wrapper instance   print t.wholeImage               #basetool internal wholeImage flag
  print t.center                   #basetool internal ROI center, object coords
  print t.size                     #basetool internal ROI size, object coords   rows,cols=image.dim()            #incoming image size
     pc=t.imgToPix((rows/2,cols/2))   #origin image center
  pmn=t.imgToPix((0,0))            #origin image "upper left"
  pmx=t.imgToPix((rows,cols))      #origin image "bottom right"
     rc=t.pixToImg(pc)                #incoming image center
  rmn=t.pixToImg(pmn)              #incoming image "upper left"
  rmx=t.pixToImg(pmx)              #incoming image "bottom right"
     print '-'*40
  PrintPoint('PIX size  ',((abs(pmx[0]-pmn[0]),abs(pmx[1]-pmn[1]))))
  PrintPoint('PIX center',pc)
  PrintPoint('PIX min   ',pmn)
  PrintPoint('PIX max   ',pmx)
  PrintPoint('IMG center',rc)
  PrintPoint('IMG size  ',((abs(rmx[0]-rmn[0]),abs(rmx[1]-rmn[1]))))
  PrintPoint('IMG min   ',rmn)
  PrintPoint('IMG max   ',rmx)  if 0:
    ref='Pixels' #none existing tool - using pixel coords
    DrawPoint(ref,t.imgToPix((0,0)),'red',1)
    DrawPoint(ref,t.imgToPix((rows,0)),'blue',2)
    DrawPoint(ref,t.imgToPix((rows,cols)),'lime',3)
    DrawPoint(ref,t.imgToPix((0,cols)),'yellow',4)
    DrawPoint(ref,pc,'white',0)
    if 1:
    ref=''  #no reference - using current tool's object coords
    DrawPoint(ref,t.imgToObj((0,0)),'red',1)
    DrawPoint(ref,t.imgToObj((rows,0)),'blue',2)
    DrawPoint(ref,t.imgToObj((rows,cols)),'lime',3)
    DrawPoint(ref,t.imgToObj((0,cols)),'yellow',4)
    DrawPoint(ref,t.imgToObj((rows/2,cols/2)),'white',0)  return 1Example 2, Accessing internal DataInput 
								page from ScriptButton on DataInput page 
 def DataInputScriptButtonClick(Sender,Args):
  #insert the button handler code
  t=GetBaseTool(Args.name)       #Args the a generic tool instance, get the BaseTool instance
  di=t.getDataInput('Config')    #get the BaseTool's 'Config' DataInput object
  if di:                         #check if available, ie. config dialog is open
    di.update()                  #refresh contentExample 3, Generic button click handling 
								in DataInput buttonsdef ButtonClicked(Sender,Args):
  #Sender is the clicked button
  #Insert the control on clicked code
  di=Args.getDataInputByChild(Sender)
  param=di.getParameterByChild(Sender)
  #print di,param.group,param.name,Sender.caption
  if param.name.find('Tower')>-1:
    if Sender.caption.find('-')>0:
      print 'decreasing %s for %s'%(param.group,param.name)
     elif Sender.caption.find('+')>0:
      print 'increasing %s for %s'%(param.group,param.name) |