Setting Color of a Rectangle in Script & Object Specs

I am trying to use:

rectangle.background = (187,187,187) to set the color of a rectangle to grey (It starts green).

rectangle is a reference to the rectangle object on the screen and has been verified as the correct object since I can print out its name and it matches what I think it should be.

I also tried rectangle.foreground = (187,187,187) and then rectangle.repaint after each one to get it to change, but no avail.

I even printed out rectangle.background and rectangle.foreground, and it registers it as changing the color (prints something like RGB (187,187,187))! Still no update on the screen, however.

What am I missing?

Also, is there a complete reference to all objects somewhere? I had to use dir(rectangle) and print it out to see the available methods and properties, but they only show them by name and not what the methods expect as arguments, return types, etc.

I ended up using a custom property I created for each rectangle I want to have color changed called “color” that acts as the driving property for the “Fill Color” property using style customizers.

I still do not understand why I cannot access fillPaint or setFillPaint() directly from the scripting environment without an error. Can anyone provide some insight?

I also tested a line, and setting the foreground property colors it in just fine using window.rootContainer.Line.foreground = (187,187,187)

Also, are the specifications available for the other objects such as rectangle (They don’t appear in the manuals from what I can see)?

Python doesn’t know how to turn a tuple of integers into a Paint object, unfortunately. Try this:

from java.awt import Color rectangle.fillPaint = Color(187,187,187)

1 Like