Skip to content

Better handling of "Dark Mode" #899

@corranwebster

Description

@corranwebster

Problem Description

When running on Mac in Dark Mode with recent Qt versions, plots render like this:

image

Reproduction Steps:

The is produced by this code:

from numpy import linspace, sin
from traits.api import HasTraits, Instance
from traitsui.api import View, Item
from chaco.api import Plot, ArrayPlotData
from enable.api import ComponentEditor

class LinePlot(HasTraits):
    plot = Instance(Plot)

    traits_view = View(
        Item('plot', editor=ComponentEditor(), show_label=False),
        width=500,
        height=500,
        resizable=True,
        title="Chaco Plot",
    )

    def _plot_default(self):
        x = linspace(-14, 14, 100)
        y = sin(x) * x**3
        plotdata = ArrayPlotData(x=x, y=y)

        plot = Plot(plotdata)
        plot.plot(("x", "y"), type="line", color="blue")
        plot.title = "sin(x) * x^3"
        return plot

if __name__ == "__main__":
    LinePlot().configure_traits()

Expected behavior:

At a minimum we should be defaulting to painting the padded area white so the labels are visible. Better would be to detect the background color of the window and adapt rendering appropriately (which would require a default "dark-mode" palette for all drawing, which is significant work)

OS, Python version: MacOS, all Python versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions