Source code for ButtonPlugin
"""
:filename: ButtonPlugin.py
:author: roar@tordivel.no
:requirements: Scorpion 8.5.0.490 or higher
Scorpion sample plugin for custom user interface
::
1.0.0.2, 11nov2015, RL: modified for autodoc
1.0.0.1, 12jul2011, RL: created
"""
__version__ = '1.0.0.2'
from Scorpion import PluginNotify,GetControlByHandle
[docs]class ButtonPlugin(object):
'''
Sample plugin with Reset and Zero buttons
Plugin has no persistance or configuration
'''
def __init__(self,cntr,name):
self.name=name
cntr.deleteControls() #delete previous added controls if any
self.reset=cntr.addControl('Button',0,0)
self.reset.left=10
self.reset.top=10
self.reset.caption='Reset'
self.reset.onClick=self.buttonClick
self.zero=cntr.addControl('Button',0,0)
self.zero.left=10
self.zero.top=self.reset.bottom+8
self.zero.caption='Zero'
self.zero.onClick=self.buttonClick
[docs] def __str__(self):
'''
return a unique persistance name for host application storage
'''
return '%s_%s'%(self.__class__.__name__,self.name)
[docs] def buttonClick(self,sender,args):
'''
button click handler
'''
if sender==self.reset:
self.reset.tag+=1
PluginNotify(self,'Reset',self.reset.tag)
elif sender==self.zero:
self.zero.tag+=1
PluginNotify(self,'Zero',self.zero.tag)
[docs]def CreatePlugin(hWnd, name=''):
'''
Scorpion Plugin Stub - Required
'''
cntr=GetControlByHandle(hWnd)
return ButtonPlugin(cntr,name)