Anyway to make drop down table bigger for touchscreen projects?

There are many different ways to do this - here's where I would probably start (if you just want to pass in that scale factor dynamically):

from com.inductiveautomation.factorypmi.application.components.PMIComboBox import DataSetListCellRenderer
from java.awt import Dimension

class BigDSRenderer(DataSetListCellRenderer):
	def __init__(self, target, scale):
		DataSetListCellRenderer.__init__(self, target)
		self.scale = scale

	def getListCellRendererComponent(self, list, value, index, isSelected, cellHasFocus):
		component = DataSetListCellRenderer.getListCellRendererComponent(self, list, value, index, isSelected, cellHasFocus)
		component.setPreferredSize(Dimension(event.source.width, event.source.height * self.scale))
		return component

target = event.source.parent.getComponent('Dropdown 1')
target.setRenderer(BigDSRenderer(target, 2))

What this does is override the __init__() method on the BigDSRenderer class. Technically, there is no __init__() method on the original Java class (Java classes work differently to Python, using overloaded constructors) but Jython translates the Java method's initialization into the __init__() form for use with Python. So, we define BigDSRenderer to have it's own custom init method - but the very first thing it does is call DataSetListCellRenderers __init__() method. This is one way to call the superclass' instantiation method (meaning it's still going to do everything that the original class did, which we want). Then it's going to take the additional argument we gave the constructor (scale) and assign it to a variable on the instance.

Then when we create an instance of the BigDSRenderer class, it expects two arguments - the target, and the scaling factor.

Disclaimer(s):
I haven't actually tested this modification, though I've done the same thing in many different areas, and some of my terminology may be slightly off (I'm mostly self-taught at this).

1 Like