Scripts w/ dark mode feature

When I was initially developing my own flavor of dark mode for the designer, I wrote this fun little script for comparing colors in the script console:

from java.awt import Window
from java.beans import PropertyChangeListener

class PythonTextAreaBackgroundListener(PropertyChangeListener):
	def __init__(self, color):
		self.color = color
	
	def propertyChange(self, event):
		if event.propertyName == "background":
			event.source.background = self.color
		

def exploreWindow(window):
	for component in window.components:
		componentClass = component.__class__.__name__
		if componentClass == 'PythonTextArea$textArea$1':
			for listener in component.propertyChangeListeners:
				if listener.__class__.__name__ == 'PythonTextAreaBackgroundListener':
					component.removePropertyChangeListener(listener)
					break
					
			if hasattr(listener, 'color') and listener.color == currentBackgroundPick:
				component.addPropertyChangeListener(PythonTextAreaBackgroundListener(comparisonBackgroundColor))
				component.background = comparisonBackgroundColor
				component.foreground = comparisonforegroundColor
				component.currentLineHighlightColor = comparisonHighlightColor
			else:
				component.addPropertyChangeListener(PythonTextAreaBackgroundListener(currentBackgroundPick))
				component.background = currentBackgroundPick
				component.foreground = currentForegroundPick
				component.currentLineHighlightColor = currentHighlighterPick
					
		exploreWindow(component)
		
currentBackgroundPick = system.gui.color('silver')
currentForegroundPick = system.gui.color('black')
currentHighlighterPick = system.gui.color(255, 255, 160)

comparisonBackgroundColor = system.gui.color('pink')
comparisonforegroundColor = system.gui.color('orange')
comparisonHighlightColor = system.gui.color(255, 255, 160)

for window in Window.getWindows():
	if window.visible and window.__class__.__name__ == 'InteractiveScriptPlayground':
		exploreWindow(window)

Simply paste the script into the script console, change the system.gui.color parameters, and run the script to toggle back and forth between background, foreground, and highlight colors in the console for purposes of comparison:



This is the one I ended up using for late night "dark mode" scripting:


It's still a positive polarity, which makes everything easier to read, but it's not blindingly bright, so I imagine my melatonin production is not completely inhibited while I'm staying up later than I should to play around with some abstract idea that popped into my head after hours.