Is there any way to make the plus sign to expand a tree view node larger?
Sure, you can use the following as your project’s Client Startup script:
[code]from javax.swing import Icon
def paintIcon(self, comp, g, x, y): from java.awt import Color s = self.size half = s/2 g.setColor(Color.WHITE) g.fillRect(x,y,s,s) g.setColor(Color.GRAY) g.drawRect(x,y,s,s) g.setColor(Color.BLACK) g.drawLine(x+3,y+half,x+s-3,y+half) if self.plus: g.drawLine(x+half,y+3,x+half,y+s-3) def getIconWidth(self): return self.size def getIconHeight(self): return self.size
from javax.swing import UIManager
You can play with the sizing by adjusting the 2nd parameter to the TreeIcon’s constructor. (the last two lines of the script)
Ok, I’ll admit it - I had fun with this one Don’t worry if this looks bizarre to you - this is one of those “pay no attention to the man behind the curtain” moments.
Hope this helps,
Works perfectly, and after looking at it, I realized that you are just creating your own Icons. (Which means, I could get creative with modifying the colors, etc. Clever. Fits in with all the other clever things this program is doing.
Thats right - Ignition is based on Java Swing, which has whats called a pluggable look-and-feel (PLAF) system. You can use the UIManager to tweak lots of things about the UI - default colors, sizes, icons, fonts, etc.
Combine this with Jython’s ability to create classes that subclass from Java classes and voilà - you can implement your own custom icons for Swing’s benefit.
Do you have/know of any good guide for the PLAF aspect of Swing?
The PLAF system itself is fairly well documented (google search should find some things) but to be honest thats probably too far-reaching for the kind of stuff most people want to do.
I find that manipulating the values in UIManager is a very handy thing to do, and for whatever reason, this aspect is poorly documented. I’ve attached an excel spreadsheet that I created a long time ago that I refer to whenever I need to mess around with this system. Maybe you’ll find it helpful. Note that when the value is something incomprehensible you should probably leave it alone. On a broader note - you’re playing with fire a bit here, so don’t be too shocked if you mess something up. You should be able to just remove that part of your script and restart the client and you’ll be fine.
UIManager.xls (99 KB)
Can I drop in the napkin look and feel.
No, if you change the whole LAF some things will break that expect the LAF that we ship with, sorry. Although I admit it would be fun
Thanks for the spreadsheet Carl, that should help!
Please repost this doc. I have recently lost it