Guest User

Untitled

a guest
May 31st, 2012
53
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # TestCmdPlugin
  2.  
  3. import win32com.client
  4. from win32com.client import constants
  5. import siutils
  6.  
  7. null = None
  8. false = 0
  9. true = 1
  10.  
  11. Application.LogMessage( "Global: %s" % __sipath__ )
  12. siutils.add_to_syspath( __sipath__ )
  13. import TestModule
  14.  
  15.  
  16. '''
  17. # Make a TestModule.py file in the same place as this testCmdPlugin.py file.
  18. # with this code:
  19.  
  20. def hello():
  21.    print "hello world."
  22.  
  23. def test():
  24.    print "it works!"
  25. '''
  26.  
  27. def XSILoadPlugin( in_reg ):
  28.     in_reg.Author = "blairs"
  29.     in_reg.Name = "TestCmdPlugin"
  30.     in_reg.Major = 1
  31.     in_reg.Minor = 0
  32.  
  33.     Application.LogMessage( "XSILoadPlugin: %s" % __sipath__ )
  34.  
  35.     in_reg.RegisterCommand("TestCmd","TestCmd")
  36.     in_reg.RegisterProperty("fooProperty")
  37.     #RegistrationInsertionPoint - do not remove this line
  38.  
  39.     return true
  40.  
  41.  
  42. def XSIUnloadPlugin( in_reg ):
  43.     strPluginName = in_reg.Name
  44.     Application.LogMessage( "XSIUnloadPlugin: %s" % __sipath__ )
  45.     Application.LogMessage(str(strPluginName) + str(" has been unloaded."),constants.siVerbose)
  46.     return true
  47.  
  48.  
  49. def TestCmd_Init( in_ctxt ):
  50.     oCmd = in_ctxt.Source
  51.     oCmd.Description = ""
  52.     oCmd.ReturnValue = true
  53.  
  54.     oArgs = oCmd.Arguments
  55.     oArgs.AddWithHandler("Arg0","Collection")
  56.     Application.LogMessage( "TestCmd_Init: %s" % __sipath__ )
  57.  
  58.     return true
  59.  
  60.  
  61. def foo():
  62.     Application.LogMessage( "foo: %s" % __sipath__ )
  63.     TestModule.test()
  64.     TestModule.hello()
  65.  
  66. def TestCmd_Execute( Arg0 ):
  67.  
  68.     Application.LogMessage("TestCmd_Execute called",constants.siVerbose)
  69.     Application.LogMessage( "TestCmd_Execute: %s" % __sipath__ )
  70.     foo()
  71.  
  72.     #
  73.     # TODO: Put your command implementation here.
  74.     #
  75.     return true
  76.    
  77.  
  78. def fooProperty_Define( in_ctxt ):
  79.     p = in_ctxt.Source
  80.     p.AddParameter2("blah",constants.siString,"",None,None,None,None,constants.siClassifUnknown,constants.siPersistable)
  81.     return True
  82.  
  83. def fooProperty_DefineLayout( in_ctxt ):
  84.     l = in_ctxt.Source
  85.     l.Clear()
  86.  
  87.     b = l.AddButton( "doButton", "DO SOMETHING" )
  88.     b.SetAttribute(constants.siUICX, 120)
  89.     b.SetAttribute(constants.siUICY, 70)
  90.  
  91.     return True
  92.  
  93. def fooProperty_OnInit():
  94.     PPG.Refresh()
  95.     xsi.LogMessage("fooProperty_OnInit called",constants.siVerbose)
  96.  
  97. def fooProperty_OnClosed():
  98.     xsi.LogMessage("fooProperty_OnClosed called",constants.siVerbose)
  99.  
  100. def fooProperty_doButton_OnClicked( ):
  101.     xsi.TestCmd()
RAW Paste Data