enthought / enthought/traitsui

ObjectEditor still not working

Open
#1,800 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
306
Forks
99
PR merge metrics
No merged PRs in 30d

Description

This is a continuation of [issue #1539](https://github.com/enthought/traitsui/issues/1539). I still get the following message when I `Add new item` using Python 3.8.12 and TraitsUI 7.2.1:

```
Traceback (most recent call last):
File "/Users/mglinsky/opt/anaconda3/envs/python38/lib/python3.8/site-packages/traitsui/qt4/table_model.py", line 256, in insertRows
editor.callx(items.insert, row + i, editor.create_new_row())
File "/Users/mglinsky/opt/anaconda3/envs/python38/lib/python3.8/site-packages/traitsui/qt4/table_editor.py", line 424, in create_new_row
return self.ui.evaluate(
File "/Users/mglinsky/opt/anaconda3/envs/python38/lib/python3.8/site-packages/traitsui/ui.py", line 693, in evaluate
return eval(function, globals(), context)(*args, **kw_args)
TypeError: eval() arg 1 must be a string, bytes or code object
Traceback (most recent call last):
File "/Users/mglinsky/opt/anaconda3/envs/python38/lib/python3.8/site-packages/traitsui/qt4/table_model.py", line 256, in insertRows
editor.callx(items.insert, row + i, editor.create_new_row())
File "/Users/mglinsky/opt/anaconda3/envs/python38/lib/python3.8/site-packages/traitsui/qt4/table_editor.py", line 424, in create_new_row
return self.ui.evaluate(
File "/Users/mglinsky/opt/anaconda3/envs/python38/lib/python3.8/site-packages/traitsui/ui.py", line 693, in evaluate
return eval(function, globals(), context)(*args, **kw_args)
TypeError: eval() arg 1 must be a string, bytes or code object
```
image

using this code
[traits_error_demo.py.zip](https://github.com/enthought/traitsui/files/7981517/traits_error_demo.py.zip)

When I use Python 3.6.13 and TraitsUI 6.1.3, I get the following error message:

```
Traceback (most recent call last):
File "/Users/mglinsky/.edm/envs/python36/lib/python3.6/site-packages/traitsui/qt4/table_model.py", line 248, in insertRows
editor.callx(items.insert, row + i, editor.create_new_row())
File "/Users/mglinsky/.edm/envs/python36/lib/python3.6/site-packages/traitsui/qt4/table_editor.py", line 398, in create_new_row
*factory.row_factory_args, **kw)
File "/Users/mglinsky/.edm/envs/python36/lib/python3.6/site-packages/traitsui/ui.py", line 791, in evaluate
return eval(function, globals(), context)(*args, **kw_args)
TypeError: eval() arg 1 must be a string, bytes or code object
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the traceback path in traitsui/qt4/table_model.py and traitsui/qt4/table_editor.py, then inspect the evaluate call in traitsui/ui.py. Run the attached traits_error_demo.py reproduction with the reported TraitsUI and Python versions. Done means the ObjectEditor can add a new item without the eval TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.