All Downloads are FREE. Search and download functionalities are using the official Maven repository.

Demo.swing.JythonConsole.Action.py Maven / Gradle / Ivy

Go to download

Jython is an implementation of the high-level, dynamic, object-oriented language Python written in 100% Pure Java, and seamlessly integrated with the Java platform. It thus allows you to run Python on any Java platform.

There is a newer version: 2.7.4
Show newest version
# I don't really like the design of this one...
from pawt import swing

class Action(swing.AbstractAction):
	def __init__(self, name, action=None, icon=None, description=None, needEvent=0):
		if action is None:
			action = name
			name = action.__name__

		#swing.AbstractAction.__init__(self, name)
		self.name = name
		self.icon = icon
		if icon:
			self.setIcon(swing.Action.SMALL_ICON, icon)
		if description:
			self.setText(swing.Action.SHORT_DESCRIPTION, description)
			self.description = description
		else:
			self.description = name
		self.action = action

		self.enabled = 1
		self.needEvent = needEvent

	def actionPerformed(self, event):
		if self.needEvent:
			self.action(event)
		else:
			self.action()

	def createMenuItem(self):
		mi = swing.JMenuItem(self.name, actionListener=self, enabled=self.enabled)
		return mi

class TargetAction(Action):
	def actionPerformed(self, event):
		if self.needEvent:
			self.action(self.getTarget(), event)
		else:
			self.action(self.getTarget())




© 2015 - 2024 Weber Informatics LLC | Privacy Policy