[Bio] / PyGUI / pluginExample.py Repository:
ViewVC logotype

View of /PyGUI/pluginExample.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (as text) (annotate)
Wed Jul 14 20:45:24 2004 UTC (15 years, 4 months ago) by efrank
Branch: MAIN
CVS Tags: V00-00-03, MigrateToNewPackage, mass-spec-01, mass-spec-03, mass-spec-02, forRick-14Jul04-1, HEAD
Changes since 1.1: +38 -27 lines
migrate to new plugin interface.
fix onLeftClick for SetLabel -> setValue

################################################################################
# Model Editor Plug-in example
#
# ModelEditor plugins are registered via File->Add Plug-In drop down menu and
# are called by right clicking on a node in the Navigator panel and selecting
# the plug-in there.
#
# Plugins interface:
#    0. Required:   Make a class inheriting from KahModule, as below.
#    1. Required:   A method called process(). process() will be passed a
#                   RecoElem corresponding to the selected node and passed
#                   a configuration section (to get job params into the module).
#
#    3. Required:   A function called registerHook.  Use it as below to register
#                   _instances_ of your module.  You can register multiple instances
#                   of multiple modules.
#
# HISTORY:
#    28 May 04 efrank   First version
#    ?? Jul 04 efrank   Change to class based
#
# BUGS:
#
#  o In the near future, we will introduce a top-level item called DataManager.
#    At that time, the arg passed to process() will be an intance of DataManager.
#
#
################################################################################

from KahOM.RecoElem           import RecoElem
from KahApp.KahModule         import KahModule


def registerHook( register ):
    register( "Print Reactions", "plugin example", MyModule( "PluginExample1") )
    register( "Another printer", "plugin example", MyModule( "PluginExample2") )


class MyModule( KahModule ):
    #------------------------------------------------------------------------
    def __init__( self, name ):
    #------------------------------------------------------------------------
        KahModule.__init__( self, name )


    #------------------------------------------------------------------------
    def process(self, theRecoElem, cfg ):
    #------------------------------------------------------------------------
        """
        Sample plug-in example.  Gathers all the reactions and prints them
        as strings.
        """

        print theRecoElem.getName()
        rxns = []
        theRecoElem.gatherReactions( rxns )

        for r in rxns:
            print r.asString()

        return



	


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3