Python Tutorial
To write a Python plug-in for Chameleon, simply complete the steps below:
1. Copy and paste the skeleton plug-in (below) into a new Python script
# ------------------------------------------- # This function returns the author of the # plug-in, and is displayed in the GUI # ------------------------------------------- def Author(): return "" # ------------------------------------------- # This function returns the category of the # plug-in, which is displayed in the GUI and # specifies where the plug-in appears in the # plug-in tree in the GUI. Use periods to # delimit. # ------------------------------------------- def Category(): return "" # ------------------------------------------- # This function returns the expected input of # the plug-in, and is displayed in the GUI # ------------------------------------------- def ExpectedInput(): return "" # ------------------------------------------- # This function returns the description of # the plug-in, and is displayed in the GUI # ------------------------------------------- def Description(): return "" # ------------------------------------------- # This function returns the expected output of # the plug-in, and is displayed in the GUI # ------------------------------------------- def Output(): return "" # ------------------------------------------- # Initializes the plug-in and checks input # If this function returns false, Execute # will not be called # ------------------------------------------- def Initialize(dataFiles,reporter,args): global myDataFiles global myReporter global myArgs #this is a list of files #from the right GUI pane myDataFiles = dataFiles #a pointer to a function #that lets you report status #back to the GUI #i.e.: myReporter("Initialized", 0) # Second parameter specifies status icon # 0 = No Icon / Success # 1 = Warning # 2 = Error # 3 = Debug myReporter = reporter # From the "CommandLineArgs" # custom property in the client myArgs = str(args) #other validation goes here #if you need return True # ------------------------------------------- # The core logic of the plug-in should be # implemented here # ------------------------------------------- def Execute(): return True # ------------------------------------------- # Any shutdown / clean-up steps go here # ------------------------------------------- def Clean(): return True
2. Implement your desired logic.
3. Place in Chameleon/pyScripts
4. Start the client and execute the plug-in
A few miscellaneous tidbits:- Make sure your users have Python 2.4 installed or your plug-ins won't show up in the GUI
- Due to a problem in Python-.Net communication, your plug-in filename may not include extra dots. (i.e. plugin.py is acceptable, but my.plugin.py is not)
- If .Net plug-ins are missing dependencies, Python plug-ins may not load. This seems weird to us too.