Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataView/Plot bgcolor can't be tuple #907

Open
corranwebster opened this issue May 17, 2023 · 0 comments
Open

DataView/Plot bgcolor can't be tuple #907

corranwebster opened this issue May 17, 2023 · 0 comments

Comments

@corranwebster
Copy link
Contributor

Problem Description

The when given a bgcolor trait which is a tuple (or other valid non-color name values) DataView code errors with an error like:

Traceback (most recent call last):
  File "/Users/cwebster/src/experiment/chaco/temp/reported_errors.py", line 29, in <module>
    LinePlot().configure_traits()
  File "/Users/cwebster/.venvs/chaco-3.11/lib/python3.11/site-packages/traits/has_traits.py", line 2164, in configure_traits
    rc = toolkit().view_application(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cwebster/src/experiment/traitsui/traitsui/qt/toolkit.py", line 237, in view_application
    return view_application.view_application(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cwebster/src/experiment/traitsui/traitsui/qt/view_application.py", line 92, in view_application
    return ViewApplication(
           ^^^^^^^^^^^^^^^^
  File "/Users/cwebster/src/experiment/traitsui/traitsui/qt/view_application.py", line 127, in __init__
    self.ui = self.view.ui(
              ^^^^^^^^^^^^^
  File "/Users/cwebster/src/experiment/traitsui/traitsui/view.py", line 457, in ui
    ui.ui(parent, kind)
  File "/Users/cwebster/src/experiment/traitsui/traitsui/ui.py", line 234, in ui
    self.rebuild(self, parent)
  File "/Users/cwebster/src/experiment/traitsui/traitsui/qt/toolkit.py", line 168, in ui_live
    ui_live.ui_live(ui, parent)
  File "/Users/cwebster/src/experiment/traitsui/traitsui/qt/ui_live.py", line 52, in ui_live
    _ui_dialog(ui, parent, BaseDialog.NONMODAL)
  File "/Users/cwebster/src/experiment/traitsui/traitsui/qt/ui_live.py", line 72, in _ui_dialog
    BaseDialog.display_ui(ui, parent, style)
  File "/Users/cwebster/src/experiment/traitsui/traitsui/qt/ui_base.py", line 294, in display_ui
    ui.owner.init(ui, parent, style)
  File "/Users/cwebster/src/experiment/traitsui/traitsui/qt/ui_live.py", line 231, in init
    self.add_contents(panel(ui), bbox)
                      ^^^^^^^^^
  File "/Users/cwebster/src/experiment/traitsui/traitsui/qt/ui_panel.py", line 270, in panel
    panel = _GroupPanel(content[0], ui).control
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cwebster/src/experiment/traitsui/traitsui/qt/ui_panel.py", line 621, in __init__
    layout = self._add_items(content, inner)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cwebster/src/experiment/traitsui/traitsui/qt/ui_panel.py", line 855, in _add_items
    editor = factory_method(
             ^^^^^^^^^^^^^^^
  File "/Users/cwebster/src/experiment/traitsui/traitsui/editor_factory.py", line 117, in simple_editor
    return self.simple_editor_class(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cwebster/src/experiment/traitsui/traitsui/editor.py", line 540, in __init__
    self.old_value = getattr(self.object, self.name)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cwebster/src/experiment/chaco/temp/reported_errors.py", line 23, in _plot_default
    plot = Plot(plotdata)
           ^^^^^^^^^^^^^^
  File "/Users/cwebster/src/experiment/chaco/chaco/plot.py", line 198, in __init__
    super().__init__(**kwtraits)
  File "/Users/cwebster/src/experiment/chaco/chaco/data_view.py", line 298, in __init__
    self._init_components()
  File "/Users/cwebster/src/experiment/chaco/chaco/data_view.py", line 361, in _init_components
    if color_table[self.bgcolor] == color_table[grid_color]:
       ~~~~~~~~~~~^^^^^^^^^^^^^^
KeyError: (1.0, 1.0, 0.9)

Proximate cause seems to be code which is trying to ensure that grids can be seen against the background.

Reproduction Steps:

Create a Plot instance with a bgcolor which is a RGB(A) tuple

Plot(bgcolor=(1.0, 1.0, 0.9))

Expected behavior:

Should set the color to the specified tuple.

OS, Python version: All

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant