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

Member index messed up with latest atom & enaml? #534

Closed
frmdstryr opened this issue Oct 3, 2023 · 4 comments · Fixed by nucleic/atom#204
Closed

Member index messed up with latest atom & enaml? #534

frmdstryr opened this issue Oct 3, 2023 · 4 comments · Fixed by nucleic/atom#204

Comments

@frmdstryr
Copy link
Contributor

I just updated to atom/enaml (0.10.2, 0.16.1) and stared getting nonsensical errors.

Traced it to when an attribute overrides an existing attribute.

For example:

from enaml.core.api import Conditional, Looper
from enaml.widgets.api import Window, Container, Label


enamldef ErrorContainer(Container): container:
    attr errors: list = []
    Looper:
        iterable << container.errors
        Label:
            text = loop.item


enamldef CustomContainer(ErrorContainer):
    attr errors: list = [] # Works fine if this is commented out
    Label:
        text = "Bar"
 

enamldef Main(Window): window:
    CustomContainer:
        pass

WTF ???

$ enaml-run tests/example.enaml 
Traceback (most recent call last):
  File "/home/test/micormamba/envs/test/bin/enaml-run", line 8, in <module>
    sys.exit(main())
  File "/home/test/micormamba/envs/test/lib/python3.10/site-packages/enaml/runner.py", line 69, in main
    window.show()
  File "/home/test/micormamba/envs/test/lib/python3.10/site-packages/enaml/widgets/window.py", line 382, in show
    self.activate_proxy()
  File "/home/test/micormamba/envs/test/lib/python3.10/site-packages/enaml/widgets/toolkit_object.py", line 213, in activate_proxy
    child.activate_proxy()
  File "/home/test/micormamba/envs/test/lib/python3.10/site-packages/enaml/widgets/toolkit_object.py", line 214, in activate_proxy
    self.activate_bottom_up()
  File "/home/test/micormamba/envs/test/lib/python3.10/site-packages/enaml/widgets/toolkit_object.py", line 236, in activate_bottom_up
    self.proxy.activate_bottom_up()
  File "/home/test/micormamba/envs/test/lib/python3.10/site-packages/enaml/qt/qt_toolkit_object.py", line 80, in activate_bottom_up
    self.init_layout()
  File "/home/test/micormamba/envs/test/lib/python3.10/site-packages/enaml/qt/qt_container.py", line 337, in init_layout
    self._setup_manager()
  File "/home/test/micormamba/envs/test/lib/python3.10/site-packages/enaml/qt/qt_container.py", line 541, in _setup_manager
    manager.set_items(self._create_layout_items())
  File "/home/test/micormamba/envs/test/lib/python3.10/site-packages/enaml/layout/layout_manager.py", line 309, in set_items
    hc = root.hard_constraints()
  File "/home/test/micormamba/envs/test/lib/python3.10/site-packages/enaml/layout/layout_manager.py", line 55, in hard_constraints
    return [d.left >= 0, d.top >= 0, d.width >= 0, d.height >= 0]
TypeError: '>=' not supported between instances of 'list' and 'int'

It seems like the member index is messed up somehow.

@MatthieuDartiailh
Copy link
Member

What Python version are you running ?

@MatthieuDartiailh
Copy link
Member

That is reminiscent of an inheritance bug that was fixed in atom. I will investigate but may not have the cycles to do so before next Monday.

@frmdstryr
Copy link
Contributor Author

Seen on 3.10.2, 3.10.12, 3.9.16

@frmdstryr
Copy link
Contributor Author

I think this should be member.set_index(existing.index) ?
member.set_index(member.index)

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

Successfully merging a pull request may close this issue.

2 participants