Source code for CurvePlugin

"""
:filename:     CurvePlugin.py
:author:       roar@tordivel.no
:requirements: Scorpion 9.0.0.493 or higher

Scorpion sample plugin for hosting controls inside a PluginManager
hosted panel/page

::

  1.0.0.2, 11nov2015, RL: modified for autodoc
  1.0.0.1, 22sep2011, RL: hides caption, enabled=System.Service
  1.0.0.2, 30may2011, RL: created
"""

__version__ = '1.0.0.3'

from Scorpion import GetBoolValue,RegisterCallback,PluginChanged,SelectTagname,GetControlByHandle

[docs]class CurvePlugin(object): ''' CurvePlugin - single curve plugin ''' def __init__(self,cntr,name): self.name=name cntr.deleteControls() #delete previous added controls if any self.curve=cntr.addControl('CurveView',0,0) self.curve.align=5 #client self.curve.showCaption=False self.curve.enableSetup=GetBoolValue('System.Service') self.curve.onChange=self.controlChange RegisterCallback('System.AccessControlChanged',self.systemAccessControlChanged)
[docs] def __str__(self): ''' return a unique persistance name for host application storage ''' return '%s_%s'%(self.__class__.__name__,self.name)
[docs] def getConfig(self): ''' returns plugin configuration as string ''' from SPB import CreateSpb spb=CreateSpb() #create a spb instance, populate with the plugin configuration #and return the xml string spb.setInt('version',1) spb.setText('config',self.curve.config) return spb.xml
[docs] def setConfig(self,value): ''' set plugin configuration from the string 'value' ''' from SPB import CreateSpb spb=CreateSpb(value) # TODO: extract plugin configuration from the spb object if spb.getInt('version')>0: self.curve.config=spb.getText('config')
[docs] def configure(self): ''' configure the plugin, return bool whether changed or not ''' param=SelectTagname(self.curve.parameter) if param<>None: self.curve.parameter=param return param<>None
[docs] def controlChange(self,sender,args): ''' notify container plugin has changed ''' #print self,'ControlChange',sender.name,args if sender==self.curve: PluginChanged(self)
[docs] def systemAccessControlChanged(self,settings,service): ''' callback when accesscontrol changes ''' self.curve.enableSetup=service
[docs]def CreatePlugin(hWnd, name=''): ''' Scorpion Plugin Stub - Required ''' cntr=GetControlByHandle(hWnd) return CurvePlugin(cntr,name)