Short Description

This script shows how to create a graphical user interface in Python, using the EzPlug SDK. Writing an Icy plugin with a graphical user interface can either be done in Java (using for example Eclipse), or with the Protocols graphical programming environment inside Icy. Sometimes, it may be desirable to have a solution that is simpler than setting up Eclipse, and more flexible than Protocols (which are very flexible !). This script is a solution to this situation. It can also be seen as a very nice way to prototype a plugin, before writing it in Java for distribution.

Versions

  • Version 2 • Released on: 2013-10-28 16:53:26
    Download
    Description:

    Wrong file was selected.

    from array import array
    
    from  java.awt import EventQueue
    
    from icy.main import Icy
    from icy.image import IcyBufferedImage
    from icy.sequence import Sequence, SequenceUtil
    from icy.type import DataType
    
    import plugins.adufour.ezplug as ezplug
    
    class MyPythonPlugin(ezplug.EzPlug):
    	def __init__(self):
    		ezplug.EzPlug.__init__(self)
    		self.inputSelector = ezplug.EzVarSequence("Input")
    		self.thresholdSelector = ezplug.EzVarDouble("Threshold value")
    
    	def getName(self):
    		return "Python Thresholder"
    
    	def initialize(self):
    		self.addEzComponent(self.inputSelector)
    		self.addEzComponent(self.thresholdSelector)
    
    	def execute(self):
    		sequence = self.inputSelector.getValue()
    		m = self.thresholdSelector.getValue()
    
    		# exit immediately if there is no input sequence
    		if sequence == None:
    			return
    
    		# convert the data to doubles so that the comparison to the threshold
    		# works everytime (it would fail with bytes because of sign issues)
    		if sequence.getDataType_() == DataType.DOUBLE:
    			doubleSeq = sequence
    		else:
    			doubleSeq = SequenceUtil.convertToType(sequence, DataType.DOUBLE, False)
    
    		# retrieve the data
    		data = doubleSeq.getDataCopyXYAsDouble(0,0,0)
    
    		for i, p in enumerate(data):
    			if p
    
    						
  • Version 1 • Released on: 2013-10-28 16:52:29
    Download
    Description:

    initial version

    from array import array
    
    from  java.awt import EventQueue
    
    from icy.main import Icy
    from icy.image import IcyBufferedImage
    from icy.sequence import Sequence, SequenceUtil
    from icy.type import DataType
    
    import plugins.adufour.ezplug as ezplug
    
    class MyPythonPlugin(ezplug.EzPlug):
    	def __init__(self):
    		ezplug.EzPlug.__init__(self)
    		self.inputSelector = ezplug.EzVarSequence("Input")
    		self.thresholdSelector = ezplug.EzVarDouble("Threshold value")
    
    	def getName(self):
    		return "Python Thresholder"
    
    	def initialize(self):
    		self.addEzComponent(self.inputSelector)
    		self.addEzComponent(self.thresholdSelector)
    
    	def execute(self):
    		sequence = self.inputSelector.getValue()
    		m = self.thresholdSelector.getValue()
    
    		# exit immediately if there is no input sequence
    		if sequence == None:
    			return
    
    		# convert the data to doubles so that the comparison to the threshold
    		# works everytime (it would fail with bytes because of sign issues)
    		if sequence.getDataType_() == DataType.DOUBLE:
    			doubleSeq = sequence
    		else:
    			doubleSeq = SequenceUtil.convertToType(sequence, DataType.DOUBLE, False)
    
    		# retrieve the data
    		data = doubleSeq.getDataCopyXYAsDouble(0,0,0)
    
    		for i, p in enumerate(data):
    			if p
    
    						

Leave a Review